There was a section on my homepage in the header.php where I wanted to add content from a page ID, it worked for me and looks like this.
$page_id = 1493;
$page_data = get_page( $page_id );
echo apply_filters(‘the_content’, $page_data->post_content);
Because this is in the header.php file it is displaying on every page, blog, posts etc when I only want it on the homepage.
What code do I add to say IF Homepage to display Else don’t display the content????
- The topic ‘Display IF Homepage Only’ is closed to new replies.