当前浏览:首页 / WordPress函数 / remove_theme_support()

remove_theme_support( string $feature )

允许主题取消对某一功能的支持

removemore...

support 支持

theme 主题more...


描述

应该在主题的 functions.php 文件中调用它。通常用于子主题以覆盖父主题的支持。

另见


参数

$feature

(string) (必填) 要删除的功能,有关可能值的列表,请参见add_theme_support()


返回

(bool|void) 功能是否已删除。



源码

查看源码 官方文档


更新日志

版本描述
3.0.0开始引入

使用示例

  • 示例1

    删除子主题中的功能
    在某些情况下,父主题可能启用了您不想在子主题中使用的功能。例如,如果您使用的父主题已启用所有页面和文章的特色图像,但您希望删除在子主题中为页面提供特色图像的功能,则可以执行以下操作:

    // 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' ) );
    }