How to Display the page title/content in WordPress Posts page?

Updated on     Kisan Patel

If you have created a home.php template file for displaying wordpress posts and you need to display the post page title and content then use below code:

For Page Title

Use get_the_title():

echo apply_filters( 'the_title', get_the_title( get_option( 'page_for_posts' ) ) );

For Page Content

Use get_post_field():

echo apply_filters( 'the_content', get_post_field( 'post_content', get_option( 'page_for_posts')));

In above both cases, we have wrap the output in an apply_filters() call, so that the post title and post content are rendered the same as they would be normally. Otherwise, the data returned via get_the_title() and get_post_field() would lack the usual formatting that WordPress applies via the_title() and the_content(), respectively.


Leave a Reply