• I need to include some html content in the header.php file. The content is one of the pages on the site – which I created using Visual Composer along with some of its custom components. With that said, I am not an expert in WP and need some insight on the best practices on how to include this page (content) in the header.php file. On suggestion is to use the following to include the page:

    <?php
    	$query = new WP_Query( 'page_id=2955' );
    	if ( $query->have_posts() ) :
    	 	while ( $query->have_posts() ) : $query->the_post(); ?>
    	 	<?php the_content(); ?>
    <?php
    	 	endwhile;
    		wp_reset_postdata();
    	endif;
    ?>

    This seems to work as expected, however, is this the best way to do this? Just trying to determine if this is the best option or if there is a better/more efficient way?

    Thanks, in advance, for any and all replies.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How To: Include page content in header.php’ is closed to new replies.