Last active
February 17, 2016 13:33
-
-
Save Stason4ik1986/f4c68cea4f43d078ed6b to your computer and use it in GitHub Desktop.
WordPress use post thumbnail as div background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if ( have_posts() ) : query_posts('p=1'); | |
| while (have_posts()) : the_post(); ?> | |
| <div <?php | |
| if ( $thumbnail_id = get_post_thumbnail_id() ) { | |
| if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) ) | |
| printf( ' style="background-image: url(%s);"', $image_src[0] ); | |
| }?> ></div> | |
| <?php endwhile; endif; wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment