Title: remove_theme_support() generates array index error
Last modified: August 20, 2016

---

# remove_theme_support() generates array index error

 *  [Mike Walsh](https://wordpress.org/support/users/mpwalsh8/)
 * (@mpwalsh8)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/)
 * I am updating a Twenty-Eleven child theme to 3.4 (actually 3.4.1) and had used`
   remove_custom_background()` and `remove_custom_image_header()` to disable custom
   headers as the child theme defines a fixed header and background.
 * I am trying to address the deprecated warning messages for `remove_custom_background()`
   and `remove_custom_image_header()` by using `remove_theme_support('custom-background')`
   and `remove_theme_support('custom-header')` but both generate a warnings:
 *     ```
       Notice:  Undefined index: wp-head-callback in C:\inetpub\wwwroot\wordpress\wp-includes\theme.php on line 1458
       Notice: Undefined index: custom_background in C:\inetpub\wwwroot\wordpress\wp-includes\theme.php on line 1460
       Notice: Undefined index: custom_image_header in C:\inetpub\wwwroot\wordpress\wp-includes\theme.php on line 1452
       ```
   
 * Looking at the wordpress\wp-includes\theme.php code, it appears that the code
   checks for the array element before trying to use it in one case but not all!
 *     ```
       switch ( $feature ) {
       		case 'custom-header' :
       			$support = get_theme_support( 'custom-header' );
       			if ( $support[0]['wp-head-callback'] )
       				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
       			remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
       			unset( $GLOBALS['custom_image_header'] );
       			break;
   
       		case 'custom-background' :
       			$support = get_theme_support( 'custom-background' );
       			remove_action( 'wp_head', $support[0]['wp-head-callback'] );
       			remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
       			unset( $GLOBALS['custom_background'] );
       			break;
       	}
       ```
   
 * The only way I’ve been able to remove these theme features in 3.4 is to do this:
 *     ```
       global $_wp_theme_features;
       	unset($_wp_theme_features['custom-header']);
       	unset($_wp_theme_features['custom-background']);
       ```
   
 * Is anyone else successfully calling `remove_theme_support()`? If so, what am 
   I doing wrong?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Global](https://wordpress.org/support/users/global_1981/)
 * (@global_1981)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917491)
 * I second this question!
 *  [codingpet](https://wordpress.org/support/users/codingpet/)
 * (@codingpet)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917492)
 * Hi,
 * It works. You need to use add_action to add them to after_setup_theme.
    Try below
   codes:
 * add_action(‘after_setup_theme’,’custom_remove_function’);
    function custom_remove_function(){
   remove_theme_support( ‘custom-header’ ); remove_theme_support( ‘custom-background’);}
   For detailed features, you can check [http://codex.wordpress.org/Function_Reference/current_theme_supports](http://codex.wordpress.org/Function_Reference/current_theme_supports)
 *  [Global](https://wordpress.org/support/users/global_1981/)
 * (@global_1981)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917493)
 * [@codingpet](https://wordpress.org/support/users/codingpet/).com yes It does 
   work but the problem is it still throws PHP notices.
 *  [codingpet](https://wordpress.org/support/users/codingpet/)
 * (@codingpet)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917494)
 * [@global_1981](https://wordpress.org/support/users/global_1981/), if you just
   installed a new wordpress 3.4.1 without any plugins activated, there will still
   be some PHP notices. These undefined index or deprecated notices are caused by
   some wordpress core codes. So I can only assume these notices are allowed by 
   the core wordpress developer(compatible with outdated themes or plugins). For
   me, I will not enable the debug mode to try to fix these notices.
 * Any other ideas?
 *  [Silvan Hagen](https://wordpress.org/support/users/neverything/)
 * (@neverything)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917529)
 * You still have this problem? I have the same thing: [http://wordpress.org/support/topic/undefined-index-custom_image_header-in-after_setup_theme-of-child-theme](http://wordpress.org/support/topic/undefined-index-custom_image_header-in-after_setup_theme-of-child-theme)
 * There is somehow a few approaches to fix this, see pastebin im my post and [http://wordpress.stackexchange.com/questions/9490/removing-custom-background-and-header-feature-in-child-theme](http://wordpress.stackexchange.com/questions/9490/removing-custom-background-and-header-feature-in-child-theme)
   but both of them aren’t really nice.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘remove_theme_support() generates array index error’ is closed to new 
replies.

 * 5 replies
 * 4 participants
 * Last reply from: [Silvan Hagen](https://wordpress.org/support/users/neverything/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/remove_theme_support-generates-array-index-error/#post-2917529)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
