The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Using Featured Image as BG not working in Loop

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #206237

    On the home page of my current project I am listing three “featured” portfolio item posts, from a custom post type. That’s straight-forward enough.

    Now, I want each of these featured items to reside in a full-screen div (accomplished by height: 100vh) with a background image of that post’s featured image.

    I thought it was easy enough; however, for some reason all three of the posts are using the featured image from the final post in the loop as their background image.

    Here’s a link to a gist of my code.

    Originally (as you can see in the gist), I declared $bg after the_post(). I tried moving it between while have_posts and the_post, and it did something really odd. When placed there, instead of using the last post’s featured image, all the posts used the second post’s featured image for their background images.

    What am I doing wrong here?

    Thanks for the help!!

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.