Currently, adding a custom background image via WordPress will attach it to the <body>
. Is there a hook to tell WordPress to attach the background image to another element?
Instead of having WordPress generating:
body.custom-background {
background-color: #ffffff;
background-image: url('background.jpg');
background-repeat: no-repeat;
background-position: top center;
background-attachment: scroll;
}
I would like to customize WordPress in a way that allow me to attach that custom background to another element instead of body.
By default, WordPress uses the
_custom_background_cb()
function to create the style you show in your question. You can use a function of your own by adding it to theadd_theme_support()
in your theme.Initially, you can use the guts of the
_custom_background_cb()
function for your own function:At this point, you should test it to make sure it works okay. Once tested, you can start making changes to
wpse_113346_custom_background_cb()
to customize the output to your liking.