如何删除类别样式(分层)分类元框
我想知道是否有人可以帮助我解决这个问题。我目前正在关注 Shibashake 的有关创建包含分类选择的自定义元框的教程:http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels。 它们展示了如何使用remove_meta_box函数删除Wordpress自动为分类创建的标准元框。唯一的问题是,由于某种原因,该函数似乎不适用于作为类别的分类法,即层次结构选项设置为 true 的分类法。我知道我的功能可以正常工作,因为设置为标签的功能很容易消失。如果这是不可能的,或者如果有一些特殊的东西我需要添加其中一个参数才能使其工作,我就不能。
示例:
$args = array(
'hierarchical' => false,
'label' =>'People',
'query_var' => true,
'rewrite' => true
);
register_taxonomy('people', 'post',$args);
remove_meta_box('tagsdiv-people','post','side');
效果很好。但是,如果我将 hierarchy 设置为“true”,则元框将保持不变。
任何人都可以透露一些信息吗?
I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels .
They show how to remove the standard metabox Wordpress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn't seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can't if it just isn't possible or if there is something special I need to add in one of the parameters to make it work.
Example:
$args = array(
'hierarchical' => false,
'label' =>'People',
'query_var' => true,
'rewrite' => true
);
register_taxonomy('people', 'post',$args);
remove_meta_box('tagsdiv-people','post','side');
That works fine. If I set hierarchical to 'true, however, the meta box stays put.
Can anyone shed some light?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 StackExchange 的 Wordpress 端找到了答案:
对于像标签一样工作的分类法,您可以使用“tagsdiv-slug”。但对于分层的,您可以使用“slugdiv”。答案可以在此处找到:
感谢@Jan Fabry 的回答
Found the answer asking over at the Wordpress side of StackExchange:
For taxonomies that work like tags, you use "tagsdiv-slug". But for ones that are hierarchical, you use "slugdiv". The answe can be found here:
Thanks to @Jan Fabry for his answer