I want to have featured image on specific div
on home page that could be changed in customizer. I saw in documentation custom background for body
(https://codex.wordpress.org/Custom_Backgrounds) But I want to make it for specific div eg. #featured-home-image
. How?
$args = array(
'default-color' => '000000',
'default-image' => '%1$s/images/background.jpg',
);
add_theme_support( 'custom-background', $args );
Use the wp-head-callback
argument to specify your own handler:
add_theme_support( 'custom-background', array(
'wp-head-callback' => 'wpse_189361_custom_background_cb',
'default-color' => '000000',
'default-image' => '%1$s/images/background.jpg',
));
function wpse_189361_custom_background_cb() {
ob_start();
_custom_background_cb(); // Default handler
$style = ob_get_clean();
$style = str_replace( 'body.custom-background', '#featured-home-image', $style );
echo $style;
}