The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

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

  • # February 4, 2013 at 4:27 pm

    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.

    # February 4, 2013 at 4:47 pm

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

    # February 5, 2013 at 3:09 pm

    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).

    # February 5, 2013 at 4:07 pm

    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.

    # February 5, 2013 at 4:26 pm

    I think get_attachment is another.

    # February 5, 2013 at 6:22 pm

    @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

    # February 5, 2013 at 7:41 pm

    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); ?>

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed