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.

closed as off-topic by fuxia Dec 2 '14 at 12:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • There's a file showing some very useful functions for modifications like that. Check /lib/functions/markup.php (I'm currently using Genesis 2.1.2) – user2076589 Dec 2 '14 at 11:32

Today I had a similar issue and this worked for me:

 * Add and extra class to the entry-content div
function vdl_entry_content_extraclass( $attributes ) {
  $attributes['class'] = $attributes['class']. ' my-custom-class';
    return $attributes;
add_filter( 'genesis_attr_entry-content', 'vdl_entry_content_extraclass' );

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.

printf( '<div class="%s">', join( ' ', get_post_class() ) );

You could write your own custom loop by copying the guts of the genesis_legacy_loop() function to a template file (like the single.php) in your child theme. Then add the logic for the background image.

$loop_counter = 0;

if ( have_posts() ) : while ( have_posts() ) : the_post();

    do_action( 'genesis_before_post' );

    printf( '<div class="%s">', join( ' ', get_post_class() ) );

        do_action( 'genesis_before_post_title' );
        do_action( 'genesis_post_title' );
        do_action( 'genesis_after_post_title' );

        do_action( 'genesis_before_post_content' );
        echo '<div class="entry-content">';
            do_action( 'genesis_post_content' );
        echo '</div>'; //* end .entry-content
        do_action( 'genesis_after_post_content' );

    echo '</div>'; //* end .entry

    do_action( 'genesis_after_post' );

endwhile; //* end of one post
    do_action( 'genesis_after_endwhile' );

else : //* if no posts exist
    do_action( 'genesis_loop_else' );
endif; //* end loop

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.