Including page content in Wordpress blog index page
- 3/2/2011
- ·
- #index
Even when a WordPress post index page is pinned to a static page, it’s sometimes nice to allow a theme’s users to edit the page’s title and provide a brief introduction to what the index represents. Unfortunately, WordPress’ default behavior limits the index page to search results. Fortunately, there’s an easy workaround: in the index template, add the following line to load up the $page
and print its content.
<?php $page = get_page( get_option( 'page_for_posts' ) ); ?>
With that out of the way, you can now fill the template with page content just like anywhere else:
<h1><?php echo apply_filters( 'the_title', $page->post_title ); ?></h1>
<?php echo apply_filters( 'the_content', $page->post_content ); ?>