我一直在使用类似于以下代码的代码添加/删除元框:
function mw_remove_postboxes() {
// Remove metaboxes from WooCommerce screens
remove_meta_box( 'wp-display-header', 'product', 'normal' );
remove_meta_box( 'wp-display-header', 'shop_order', 'normal' );
remove_meta_box( 'wp-display-header', 'shop_coupon', 'normal' );
remove_meta_box( 'wp-display-header', 'acf', 'normal' );
// Remove metaboxes from Banners post type management
remove_meta_box( 'wp-display-header', 'banners', 'normal' );
remove_meta_box( 'wpseo_meta', 'banners', 'normal' );
}
add_action( 'do_meta_boxes' , 'mw_remove_postboxes' );现在我有一个稍微不同的需求,在这里,我需要从编辑-tags.php屏幕/edit-tags.php?action=edit&taxonomy=featured&tag_ID=22&post_type=page中删除一个元框。
这是编辑分类法的页面。我找到了从自定义post类型中删除分类法元框的方法,但本例中没有。
你能帮忙吗?
发布于 2014-10-11 14:37:57
可以用jQuery完成:
$('h3').each(function() {
if( $(this).text() === 'Header' ) {
// Text after element: http://stackoverflow.com/a/6925135/1287812
var a = $(this).parent().first().contents().filter(function() {
return this.nodeType == 3;
});
a.remove();
$(this).hide();
$(this).next().hide();
}
});或者使用这个master lesson on removing hooks registered by anonymous objects。从WPSE中提取函数remove_anonymous_object_filter()并调用它如下:
add_action( 'admin_init', 'kill_anonymous_example', 0 );
function kill_anonymous_example()
{
foreach ( get_taxonomies( array( 'show_ui' => true ) ) as $_tax )
remove_anonymous_object_filter(
"{$_tax}_edit_form",
'Obenland_Wp_Display_Header', // plugin instantiation on Obenland_wpdh_instantiate(new Obenland_Wp_Display_Header)
'edit_form'
);
}https://stackoverflow.com/questions/26304820
复制相似问题