Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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' );
share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

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.

add_action('after_setup_theme', 'remove_theme_features', 11 );

function remove_theme_features() {
    $GLOBALS['custom_background']   = 'kill_theme_features';
    $GLOBALS['custom_image_header'] = 'kill_theme_features';
}
class kill_theme_features {
    function init() { return false; }
}

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..

share|improve this answer
    
only this worked so far +1 –  Atif Mohammed Ameenuddin Feb 17 '11 at 8:52
    
I tried all the suggestions posted myself(i use a child theme to), and none of them worked for me, so i was determined to find a method that worked. It's odd really, the method Rarst posted should(in theory at least) do exactly what you're asking, so i can only assume it's bugged(or that we're all doing it wrong, lol). –  t31os Feb 17 '11 at 11:38
add comment

Child theme is processed before parent theme. So your function is getting hooked earlier and fires before twentyten_setup().

Try:

add_action( 'after_setup_theme', 'my_child_theme_setup', 11 );

Alternatively you can copy twentyten_setup() to your child theme and modify, since it is declared conditionally on ! function_exists( 'twentyten_setup' )

share|improve this answer
add comment

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.

share|improve this answer
    
edit, still no luck –  Atif Mohammed Ameenuddin Feb 16 '11 at 10:17
1  
@atif089 edited, maybe this will help. –  Cronco Feb 16 '11 at 10:58
add comment

try:

function my_child_theme_setup() {
    global $_wp_theme_features;
    unset( $_wp_theme_features['custom-background'] );
    unset( $_wp_theme_features['custom-header'] );

}

add_action( 'after_setup_theme', 'my_child_theme_setup' );

Hope this helps

share|improve this answer
add comment

From a brief search through core, i couldn't verify the existance of remove_custom_image_header() *). I only found add_custom_image_header() that uses add_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:

function remove_theme_features() 
{
    $GLOBALS['custom_background']   = '__return_false';
    $GLOBALS['custom_image_header'] = '__return_false';
}
add_action( 'after_setup_theme', 'remove_theme_features', 20 );

It's just shorter.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.