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!!