Snippets: Replace Site Header With Visual Composer or Other Page Content

IMPORTANT: In Total 3.5.2 we added a new "Header Builder" function. Simply go to Theme Panel > Header Builder to replace your header with content from any page!

// Replace the header
function myprefix_replace_site_header() {

	// First lets remove all header actions
	remove_all_actions( 'wpex_hook_header_top' );
	remove_all_actions( 'wpex_hook_header_inner' );
	remove_all_actions( 'wpex_hook_header_bottom' );

	// Now lets replace the header content
	add_action( 'wpex_hook_header_inner', 'myprefix_return_site_page_content', 0 );

add_action( 'init', 'myprefix_replace_site_header', 10 );

// Output the contents of a custom page
function myprefix_return_site_page_content() {
	$page_id = 170; // Change this to the page ID you want to grab content from
	echo do_shortcode( get_post_field( 'post_content', $page_id ) );

// Add your page id to the list of IDs so any custom CSS from the Visual Composer gets added to your site
// such as the Visual Composer "Design Options" and "CSS" modules (backgrounds, borders, etc).
// TOTAL 3.1.2 + required
function myprefix_wpex_vc_css_ids( $ids ) {
	$ids[] = 170;
	return $ids;
add_filter( 'wpex_vc_css_ids', 'myprefix_wpex_vc_css_ids' );

Snippet Type: PHP

Posted Under: Header

All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)