Wordpress - 在 QuickEdit 中隐藏分类字段
Wordpress - Hide taxonomy fields in QuickEdit
为自定义 post 类型创建分类后,它们都会显示在 QuickEdit 中。我试图隐藏它们以使用其他自定义字段的菜单,但不知道该怎么做。感谢您的帮助。
尝试 javascript。 (我用的是jquery)。
jQuery(document).ready(function($){'use strict';
if ($('.post-type-custom').length) {
$('.taxonomy-checklist').prev().prev().hide(); // to hide title
$('.taxonomy-checklist').hide(); //to hide box
} });
将此代码添加到 js 文件中(假设 customadmin.js 并假设它位于 js 文件夹中主题文件夹) 并在管理员端排队文件:
if(!function_exists('addstyle_to_admin')):
function addstyle_to_admin() {
if(is_admin()){
wp_enqueue_script('myadminpanelscript',get_template_directory_uri() . '/js/customadmin.js',array('jquery'),false,false);
}
}
add_action('admin_enqueue_scripts','addstyle_to_admin');
endif;
晚会有点晚了,但为了将来参考,您可以使用自 Wordpress 4.2.0 以来的过滤器:quick_edit_show_taxonomy
。比 javascript 方法干净得多:)
更好的是,在注册分类法时,您现在可以将其传递给 register_taxonomy 函数,如下所示:
'show_in_quick_edit' => false
这似乎从 Wordpress 4.2 开始有效。
add_filter('quick_edit_show_taxonomy', 'listing_remove_taxonomy_from_quick_edit', 10, 3);
function remove_taxonomy_from_quick_edit($show_in_quick_edit, $taxonomy_name, $post_type) {
if ('post_type' === $post_type) {
return false;
}
return $show_in_quick_edit;
}
希望这会奏效
为自定义 post 类型创建分类后,它们都会显示在 QuickEdit 中。我试图隐藏它们以使用其他自定义字段的菜单,但不知道该怎么做。感谢您的帮助。
尝试 javascript。 (我用的是jquery)。
jQuery(document).ready(function($){'use strict';
if ($('.post-type-custom').length) {
$('.taxonomy-checklist').prev().prev().hide(); // to hide title
$('.taxonomy-checklist').hide(); //to hide box
} });
将此代码添加到 js 文件中(假设 customadmin.js 并假设它位于 js 文件夹中主题文件夹) 并在管理员端排队文件:
if(!function_exists('addstyle_to_admin')):
function addstyle_to_admin() {
if(is_admin()){
wp_enqueue_script('myadminpanelscript',get_template_directory_uri() . '/js/customadmin.js',array('jquery'),false,false);
}
}
add_action('admin_enqueue_scripts','addstyle_to_admin');
endif;
晚会有点晚了,但为了将来参考,您可以使用自 Wordpress 4.2.0 以来的过滤器:quick_edit_show_taxonomy
。比 javascript 方法干净得多:)
更好的是,在注册分类法时,您现在可以将其传递给 register_taxonomy 函数,如下所示:
'show_in_quick_edit' => false
这似乎从 Wordpress 4.2 开始有效。
add_filter('quick_edit_show_taxonomy', 'listing_remove_taxonomy_from_quick_edit', 10, 3);
function remove_taxonomy_from_quick_edit($show_in_quick_edit, $taxonomy_name, $post_type) {
if ('post_type' === $post_type) {
return false;
}
return $show_in_quick_edit;
}
希望这会奏效