返回介绍

remove_theme_support()

发布于 2017-09-11 10:09:33 字数 2855 浏览 1058 评论 0 收藏 0

remove_theme_support( string $feature )

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


description

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


参数

$feature

(string) (Required) the feature being added


返回值

(bool|void) Whether feature was removed.


源代码

File: wp-includes/theme.php

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

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/theme.php: _remove_theme_support()

Used By

  • wp-includes/deprecated.php: remove_custom_image_header()
  • wp-includes/deprecated.php: remove_custom_background()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Removing a Feature In a Child Theme
    In some cases, a Parent Theme may have activated a feature that you do not want to have available in your Child Theme. For instance, if you are using a parent theme that has activated Featured Images for all Pages and Posts, but you’d like to remove the functionality of having Featured Images for Pages in your Child Theme, you could do something like this:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文