the_post_thumbnail as background image?
-
Hi, I have a question regarding setting the post thumbnail as a background image. I want div.portfolio-item to have the_post_thumbnail set as a background image. Currently, it echoes the post thumbnail as just an image. Is there a way to accomplish this altering the code below?
Thanks for any help!
<?php /* Template Name: Portfolio */ ?> <?php get_header(); ?> <div class="row"> <div class="span12"> <div class="title"> <h1> <?php the_title(); ?> </h1> </div> </div> </div> <?php the_content(); ?> <div id="portfolio-wrapper" class="row"> <?php query_posts('cat=21'); if(have_posts()) : while(have_posts()) : the_post(); ?> <div <?php post_class(array('portfolio-item','span4'));?>> <?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" rel="lightbox[' . the_title_attribute('echo=0') . ']" >'; the_post_thumbnail('large'); echo '</a>'; } ?> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> <div class="item-description alt"> <?php the_content(); ?> <hr /> <p><?php the_time('j F Y') ?></p> </div> </div> <?php endwhile; endif; ?> </div> <?php get_footer(); ?>
- The topic ‘the_post_thumbnail as background image?’ is closed to new replies.