62 | Show Page Title and Content of the ‘Posts Page’ in WordPress

g+

When you set a static front page and at the same time set a Posts Page, WordPress will automatically use index.php (or home.php *) to display the Posts Page; as described in the Codex, you’ll lose the output of the title and content of that page.
To show this information on the Posts Page, for instance as an introduction for the posts, add some code to index.php (or home.php):

<?php //this is to output the page title and content for a 'page for posts' page as set under  'settings' - 'reading'
	if( is_home() && !is_paged() && get_option('page_for_posts') ) { 
	$posts_page_id = get_option('page_for_posts'); ?>			
	<header class="entry-header">
		<h1 class="entry-title"><?php echo get_the_title($posts_page_id); ?></h1>
	</header><!-- .entry-header -->
	<?php $posts_page = get_page( $posts_page_id ); ?>
	<div class="entry-content posts-page-entry-content">
	<?php echo apply_filters('the_content', $posts_page->post_content); ?>
	</div><!-- .posts-page-entry-content -->	
<?php } ?>
This entry was posted in Tips & Tricks, WordPress and tagged , , , . Bookmark the permalink.

7 Responses to Show Page Title and Content of the ‘Posts Page’ in WordPress

  1. Caroline comments:

    Paso cinco. Semicírculos para las orejas y algunas líneas para
    simular los diferentes pliegues dibujos de amor a lapiz tumblr las orejas.

  2. Shenna comments:

    Ѕo when іt’s thаt time оf yr tо specific yoᥙr love, friendship ߋr distinctive relationship, tᥙrn to for Valentine’ѕ flowers that tҺey’re positive tߋ cherish.

    Hᥱrе is my ⲣage; beautiful valentines day flowers

  3. Bharat comments:

    Dear Michael,
    I am really new to wordpress development. I want to add title to every page & post manually. Can you please give me code as you have given for meta description i n your post.

  4. Ian comments:

    After much scratching of the head, and trawling through various forums – i finally found this, which was the solution to my problem!

    Massive thanks 😀

  5. Matthew comments:

    Hi Alchymyth,

    I copied the index.php to my child theme and add your code to it, it works like a charm!

    However, I am wondering if there is anyway that we can further improve this method. For example, I want to make this index.php as one of my page templates. I found when I change the name of index.php, it doesn’t work. Would you mind adding the solution to your post, I think that will benefit lots of WordPress users.

    Thanks and regards,

    Matthew

    • Michael replies:

      Hi Matthew,
      for a page template, the page title and content are directly available with a ‘default’ loop, which you could have before the custom template code. see the Codex; or check the WordPress support forum for possible solutions.
      cheers,
      Michael

  6. Pingback: Show Page Title and Content of the 'Posts Page' in WordPress … | Scion Players

    g+

    05/09/2012 | […] Show Page Title and Content of the 'Posts Page' in WordPress … This entry was posted in…

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*