Is there a way to set the featured image of a page as the background? I’ve been searching and found couple of lines of code on google.
https://wordpress.org/support/topic/using-this-code
Any idea on how to approach this?
This function should do the job:
add_filter( 'theme_mod_background_image', 'enlightenment_featured_image_background' );
function enlightenment_featured_image_background( $image ) {
if( is_singular() && has_post_thumbnail() ) {
return wp_get_attachment_url( get_post_thumbnail_id() );
}
return $image;
}