treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] How can I grab the Featured Thumbnail attached to the Blog page?

  • I have a static home page and another page for my blog. Every time I try to grab the thumbnail I've attached to the Blog page itself it just grabs the one from the first post.

  • You need to set a query to get the thumbnails for each post.

  • I'm not trying to get the thumbnails for each post. I am only trying to get the thumbnail for the current page. On other pages it's easy, you can just use the_post_thumbnail(), but if you use that on the blog page, it just grabs the thumbnail of the first post (even if I call it before the loop).

  • From the codex:

    This tag must be used within The Loop. Use get_the_post_thumbnail($id, $size, $attr ) instead to get the featured image for any post.

    http://codex.wordpress.org/Function_Reference/the_post_thumbnail

  • I think get_attachment is another.

  • @begetolo, I'm NOT trying to get the thumbnail from a POST. I'm trying to get the thumbnail from the current PAGE.

    @chrisburton, I've tried various get_attachment options and all ended up the same. Any time I try to grab data from the Blog page, it's just grabbing them from the posts from the loop, even though my code comes before the loop

  • I've figured it out. I get the blog page ID, and then that ID lets me get the proper thumbnail.

    <?php $postspage_id = get_option('page_for_posts'); echo get_the_post_thumbnail($postspage_id); ?>