Created
October 4, 2013 02:12
-
-
Save intelliweb/6819984 to your computer and use it in GitHub Desktop.
WP: Featured image as 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 | |
// Featured image as background | |
add_action('wp_head', 'intw_head'); | |
function intw_head() { | |
if( is_page() && !is_front_page() ) { | |
if( has_post_thumbnail() ) { | |
$featimg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false ); | |
$featimg_url = $featimg[0]; | |
} else { | |
$featimg_url = get_bloginfo('stylesheet_directory') . '/images/bg.jpg'; | |
} | |
echo '<style type="text/css" media="screen">'; | |
echo '.builder-module-content-background-wrapper { background: url(' . $featimg_url . ') top center no-repeat; }'; | |
echo '</style>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment