WordPress函数remove_theme_support()

描述:

禁用/删除主题功能支持

用法:

<?php remove_theme_support( $feature ); ?>

参数:

$feature

(string) (必填) 要禁用的功能名称.

功能列表:

  • ‘post-formats’
  • ‘post-thumbnails’
  • ‘custom-background’
  • ‘custom-header’
  • ‘automatic-feed-links’
  • ‘html5’
  • ‘title-tag’
  • ‘menus’

默认值: None

示例:

// in your Child Theme's functions.php    

// Use the after_setup_theme hook with a priority of 11 to load after the
// parent theme, which will fire on the default priority of 10
add_action( 'after_setup_theme', 'remove_featured_images_from_child_theme', 11 ); 

function remove_featured_images_from_child_theme() {

    // This will remove support for post thumbnails on ALL Post Types
    remove_theme_support( 'post-thumbnails' );

    // Add this line in to re-enable support for just Posts
    add_theme_support( 'post-thumbnails', array( 'post' ) );
}

源文件:

/**
 * Allows a theme to de-register its support of a certain 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.
 *
 * @since 3.0.0
 * @see add_theme_support()
 * @param string $feature the feature being added
 * @return bool|void Whether feature was removed.
 */
function remove_theme_support( $feature ) {
	// Blacklist: for internal registrations not used directly by themes.
	if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) )
		return false;

	return _remove_theme_support( $feature );
}