Return to Snippet

Revision: 35688
at November 15, 2010 03:12 by jli


Updated Code
<?php if (has_post_thumbnail( $post->ID )) : ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div id="custom-bg" style="background-image: url('<?php echo $image; ?>')">

</div>
<?php endif; ?>

Revision: 35687
at November 12, 2010 02:29 by jli


Initial Code
<?php if (has_post_thumbnail( $post->ID ) : ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div id="custom-bg" style="background-image: url('<?php echo $image; ?>')">

</div>
<?php endif; ?>

Initial URL

                                

Initial Description
This code will retrieve the url of a featured image in order to use it as a background.

Initial Title
Wordpress - Get featured image url

Initial Tags
url, image, wordpress

Initial Language
PHP