Apply a CSS Class to div background (post_image)
-
I have the following code, but I need to apply a class to the post image that’s called to show as the div background. The style I want to apply is CSS Filter, so currently when applied it will apply the filter to the div content – which I don’t want.
Basically I need an alternative that will allow me to apply a class to the image in the background only. It’s a custom built theme, so can edit the functions.php etc as needed.Current code:
<div class="row home-services small-up-1 medium-up-2 large-up-3"> <?php query_posts('category_name=services&showposts=6'); while ( have_posts() ) : the_post(); ?> <?php $srvbg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID)); ?> <div class="column" style="background: url(<?php echo $srvbg[0]; ?> ) !important;"> <div class="home-serv-content"> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> <a class="button align-self-bottom" href="<?php the_permalink(); ?>" class="info">Read More...</a> </div> </div> <?php endwhile; ?> </div>
The topic ‘Apply a CSS Class to div background (post_image)’ is closed to new replies.