When WordPress has a static front page (as set in “Settings” > “Reading”), it is often useful to display introductory content on the page that has been selected for posts.
The posts page is determined by the ‘page_for_posts’ value in the ‘option_name’ column in the WordPress options table. The ID of this page can be retrieved by:
This allows the page content and featured image to be displayed in the template.
Display Page Content
By default, the page for posts uses the WordPress
home.php template. To access the page content in this template:
Where the Hell is the Editor?
WordPress (as of version 4.5.1 anyway) has an extremely annoying characteristic whereby the content editor is not shown on the page for posts if the
post_content field is empty. Instead, you get an annoying message telling you what you already know - that this is the page selected to display blog posts.
There are two fixes:
- Temporarily set a different page for blog posts, add some content to your original posts page, and then switch the setting back to the original posts page
- Remove the annoying message and add back the editor by hooking onto
When I first noticed this, it bugged the hell out of me - since my development site had page content, the editor displayed normally (not so in the staging site).
The culprit is this little diamond in
The second, less hackish fix:
Credit for this goes to crgeary
I can’t imagine why this “functionality” has been built in. It would surely be better for WP core to be less opinionated - but at least it’s fairly easy to undo the damage.
comments powered by Disqus