I made a home.php file and called it Blog.
It set it to be the Posts page, but I would like to add a title that will be displayed in that page (the title of page or content).
e.g:
Posts page:
Page title
(Maybe page content)
== Posts ==
Post Title
Post Content
Post Title and so on
I’m assuming the following:
home.php
template file in your ThemeBecause of the special, reserved nature of
home.php
, and also forpage_for_posts
, you cannot use the normal methods to access the$post
object for the Blog static page. You can, however, retrieve the post title and post content for this page. The key is to reference the post ID viaget_option( 'page_for_posts' )
.Page Title
Use
get_the_title()
:Page Content
Use
get_post_field()
:In both cases, 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 viaget_the_title()
andget_post_field()
would lack the usual formatting that WordPress applies viathe_title()
andthe_content()
, respectively.as what I understand, you need
single_post_title()