I am creating a child theme using twentyten as my base. I am looking for a way to remove the features of adding custom header and background without touching functions.php
file in the parent theme.
no luck with this 🙁
function my_child_theme_setup() {
remove_theme_support('custom-background');
remove_theme_support('custom-header');
}
add_action( 'after_setup_theme', 'my_child_theme_setup' );
Both the header and background image features setup some globals in order to work, unsetting those globals seems to have some effect, and at the least removes them from the administration side.
There’s expectations for a class name to be provided as a callback for both of these features, and both expect the given class to have an init method. The solution was to create a dummy class that does nothing and update the globals, which effectively kills off the theme background and header pages in the admin area.
Hope that helps..
Child theme is processed before parent theme. So your function is getting hooked earlier and fires before
twentyten_setup()
.Try:
Alternatively you can copy
twentyten_setup()
to your child theme and modify, since it is declared conditionally on! function_exists( 'twentyten_setup' )
remove_theme_support should do the trick.
EDIT-
It seems custom headers & custom backgrounds have their own functions for this: Custom Headers . I assume the same type of function should be for custom backgrounds, but I can’t find it in the reference, searching for it in the files.
EDIT 2 –
The
remove_custom_image_header
function is available only from 3.1, according to the codex. I would suggest Rarst’s suggestion right now.try:
Hope this helps
From a brief search through core, i couldn’t verify the existance of
remove_custom_image_header()
*). I only foundadd_custom_image_header()
that usesadd_theme_support()
, so this should work.If it doesn’t you can go one step closer to core and use the Theme Modifications API. Strange as it is: The API only has a function that removes all modifications:
remove_theme_mods()
that takes no additional parameters.After thinking about it, your best chance is to filter it:
add_filter( "theme_mod_$name", 'your_callback_fn' );
, but i’m not completely sure if it removes it from admin UI (10% chance it does). So maybe you’ll have to unset that menu entries via another function.Anyway: Take a look into
~/wp-includes/theme.php
… that’s the “twenty ten” core support file (that won’t be used by other themes i guess).*) This is really strange…
Edit:
remove_custom_image_header()
now is available with WP 3.1+.And a short edit of @t310s answer:
It’s just shorter.