I feel like this should be an easily found answer but so far I havent found anything.
So the genesis loop automatically wraps the posts in a div like so:
<div class="post-4006 post type-post status-publish
format-standard hentry category-blog tag-foia tag-nmb entry">...</div>
Well I need to change that markup to add a background image to each post. Im trying to take the featured image and apply it to the div background, so I would need my posts mark
<div style="url_to_post_thumbnail" class="post-4006 post type-post status-publish
format-standard hentry category-blog tag-foia tag-nmb entry">...</div>
I can do the logic just fine but I dont know what filter to modify the post wrapper. and I cant seem to find it.
Today I had a similar issue and this worked for me:
In my case, I am adding this code to my single-portfolio.php template because I only want to add that class in that template. If you paste this code in functions.php the change will apply all templates. You could also use conditional tags inside the function to decide where to apply this change.
As I only started this week with Genesis, and this is my first child theme, I don´t know if this is the right way to do it, but I hope it will help you.
That markup is hard coded into the
genesis_legacy_loop()
Genesis function. There is no filter provided to add attributes to that markup.You could write your own custom loop by copying the guts of the
genesis_legacy_loop()
function to a template file (like thesingle.php
) in your child theme. Then add the logic for the background image.By leaving all the normal genesis actions in this loop, you allow all the features built in to Genesis to function correctly and can change the markup to your liking.