Last active
August 29, 2015 14:13
-
-
Save timkinnane/02f6e2a93a04ed328b15 to your computer and use it in GitHub Desktop.
Apply custom background style on an element within the body. e.g. If you're using off-canvas and on-canvas containers, you may want the background only on the #canvas. It overwrites the theme support feature array value with a custom callback, but I haven't tested what happens if other key/values are defined elsewhere. There are no filters yet f…
This file contains 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
function nested_custom_background_cb() { | |
ob_start(); | |
_custom_background_cb(); | |
$bg_style_tag = ob_get_contents(); | |
ob_end_clean(); | |
$bg_style_tag = str_replace( 'body.custom-background', 'body.custom-background #canvas', $bg_style_tag ); | |
echo $bg_style_tag; | |
} | |
add_theme_support( 'custom-background', array( 'wp-head-callback' => 'nested_custom_background_cb' ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment