remove_theme_support

Allows a theme to de-register its support of a certain feature.

Description

(bool|void) remove_theme_support( (string) $feature ); 

Should be called in the theme's functions.php file. Generally would be used for child themes to override support from the parent theme.

Returns (bool|void)

Whether feature was removed.

Parameters (1)

0. $feature (string)
The feature being added

Usage

  1. if ( !function_exists( 'remove_theme_support' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // the feature being added 
  5. $feature = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = remove_theme_support($feature); 
  9.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function remove_theme_support( $feature ) { 
  2. // Blacklist: for internal registrations not used directly by themes. 
  3. if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) 
  4. return false; 
  5.  
  6. return _remove_theme_support( $feature ); 
  1. function _remove_theme_support( $feature ) { 
  2. global $_wp_theme_features; 
  3.  
  4. switch ( $feature ) { 
  5. case 'custom-header-uploads' : 
  6. if ( ! isset( $_wp_theme_features['custom-header'] ) ) 
  7. return false; 
  8. add_theme_support( 'custom-header', array( 'uploads' => false ) ); 
  9. return; // Do not continue - custom-header-uploads no longer exists. 
  10.  
  11. if ( ! isset( $_wp_theme_features[ $feature ] ) ) 
  12. return false; 
  13.  
  14. switch ( $feature ) { 
  15. case 'custom-header' : 
  16. if ( ! did_action( 'wp_loaded' ) ) 
  17. break; 
  18. $support = get_theme_support( 'custom-header' ); 
  19. if ( isset( $support[0]['wp-head-callback'] ) ) { 
  20. remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 
  21. if ( isset( $GLOBALS[custom_image_header] ) ) { 
  22. remove_action( 'admin_menu', array( $GLOBALS[custom_image_header], 'init' ) ); 
  23. unset( $GLOBALS[custom_image_header] ); 
  24. break; 
  25.  
  26. case 'custom-background' : 
  27. if ( ! did_action( 'wp_loaded' ) ) 
  28. break; 
  29. $support = get_theme_support( 'custom-background' ); 
  30. remove_action( 'wp_head', $support[0]['wp-head-callback'] ); 
  31. remove_action( 'admin_menu', array( $GLOBALS[custom_background], 'init' ) ); 
  32. unset( $GLOBALS[custom_background] ); 
  33. break; 
  34.  
  35. unset( $_wp_theme_features[ $feature ] ); 
  36. return true;