Getting Data from Your Posts Page in WordPress


The Problem

With most of the WordPress sites I develop, I don’t want the homepage to be the default blog page with a loop of posts. Luckily, there’s an easy remedy by setting the front page (under Settings -> Reading) to a page called Home and the posts page to a page called Blog.

That works great… at least until you’re trying to pull a featured image or custom field from the Blog page. Because of how it overrides the page template to be index.php, if you call the function the_post_thumbnail(), you’ll get the thumbnail of the most recent blog post instead of the page. Same goes for any other post functions like the_content() or the_permalink(). Here’s how I suggest getting data from your posts page.

The Solution: get_option( ‘page_for_posts’)

For a long time, I wasn’t quite sure how to get around this issue, but then I found this…

All it does is return the page id for whatever you have set as your posts page. From there, you can use that ID to do almost anything else you need to like…

Get the featured image of the Blog page:

Get an ACF field from the Blog page:

Set up the post data for the Blog page:


Even though this is such a simple solution, it was one of the more difficult things for me to find because a search for it returned so many irrelevant results. Hopefully it will help you out. I would love to hear in the comments if you have another way of accomplishing the same thing.

Give me your email address

I'm going to level with you. I have no idea if I'll ever send anything out to this list, but I promise if I do, it will be worth it. I suggest signing up. At worst, you'll never hear from me again. Best case, you'll get something useful.

You have Successfully Subscribed!