Background as Thumbnail image
-
Hi there,
I am having trouble using an image thumbnail as a background image.
The code doesn’t break but it is adding “<img src=” where the url is meant to be.
<?php if (have_posts()): while (have_posts()) : the_post(); ?> <!-- article --> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <!-- post thumbnail --> <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?> <?php $thumbnail = get_the_post_thumbnail( null, $size, $attr ); ?> <div id="work" style="background-image:url('<?php echo $thumbnail ?> <a class="title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </div> <?php endif; ?> <!-- /post thumbnail --> </article> <!-- /article --> <?php endwhile; ?> <?php else: ?> <!-- article --> <article><h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2></article> <!-- /article --> <?php endif; ?>
Thanks for any help,
Phil
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Background as Thumbnail image’ is closed to new replies.