Lego2012
9/26/2016 - 10:08 PM

Use different featured Images as a Body

Use different featured Images as a Body

/* Add this to custom CSS */
/* The following is a fix for some mobile browsers */
html,body {
height:100%;
min-height:100%;
margin:0!important;
}

body {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
//  You can set a "default" body background image in Dynamik Design - Body. It will be displayed when no featured image available.

//*https://journalxtra.com/wordpress/quicksnips/use-wordpress-featured-image-post-page-background-picture/
add_action( 'wp_head', 'vr_set_featured_background', 99);
function vr_set_featured_background() {
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), full, false );
if ($image_url[0]) {
//* Close php tag for body styles
?>

<style>
body {
background:url(<?php echo $image_url[0]; ?>) #fff fixed center top no-repeat;
}
/* Uncomment if the image hangs low in a Genesis theme */
/*.site-inner {
padding-top:0!important;
padding-bottom:0!important;
}*/
</style>
<?php
//* Open php tag again for rest of functions	
}
}