2

I've been adding/removing meta boxes with code similar to:

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

Now I have a slightly different need, where I need to remove a meta box from the edit-tags.php screen /edit-tags.php?action=edit&taxonomy=featured&tag_ID=22&post_type=page

This is the page for editing a taxonomy. I've found ways to remove a taxonomy meta box from custom post types, but none for this case.

Could you help?

Luis Martins
  • 1,421
  • 2
  • 18
  • 32
  • Depends on who put it there and how... Without references, hard to tell. – brasofilo Oct 10 '14 at 19:25
  • The `wp-display-header`for instance is created by the WP Custom Header plugin and automatically associated to every post type. In most cases that's ok, but in this case, im editing a taxonomy which has no front-end so makes no sense to have a header selection. Hope this clear things up a bit. – Luis Martins Oct 11 '14 at 13:54

1 Answers1

0

Can be done with 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(); 
    } 
});

Or using this master lesson on removing hooks registered by anonymous objects. Pull the function remove_anonymous_object_filter() from WPSE and call it like:

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'
        );
}
Community
  • 1
  • 1
brasofilo
  • 25,496
  • 15
  • 91
  • 179