• Resolved aaronrobb

    (@aaronrobb)


    Hi!
    I’m having an issue with removing a custom taxonomy meta box from our edit page.
    The code i’m using is below, but nothing is happening. Is there something I’m missing, or another way to do this?
    I still want to see the taxonomy in the side menu, so just using the ‘show ui = false’ won’t work.

    I’ve tried:

    function sb_remove_trackbacksdiv(){
    	remove_meta_box( 'product-category', 'business', 'normal' );
    }
    
    add_action( 'admin_menu', 'sb_remove_trackbacksdiv' )

    and

    function sb_remove_taxonomy_box() {
    	$slug = 'product-category'; // this is custom taxonomy slug
    	$post_type = 'business'; // custom post type
    
    	remove_meta_box( $slug.'div', $post_type, 'side' );
    }
    
    add_action( 'admin_menu', 'sb_remove_taxonomy_box' );

    My cpt is ‘business’ and the taxonomy slug is ‘product-category’.
    Its Hierarchical as well.
    And i’m on the Roots/Sage theme.

    Any help would be great.
    Thanks!

    https://www.ads-software.com/plugins/custom-post-type-ui/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I am using the first method and it works for me. Double check if you have the right parameters of remove_meta_box(). Double check your meta box ID

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    According to the codex page: https://codex.www.ads-software.com/Function_Reference/remove_meta_box the first parameter is going to be like: ‘{$tax-name}div’ which is what matches for “Hierarchical custom taxonomies metabox”. So the second example above should be the one you’re using.

    If you can provide the post type and taxonomy exports, I can try it out myself, to make sure I’m using the exact same settings you are for this.

    Thread Starter aaronrobb

    (@aaronrobb)

    Michael,
    Here’s the CPT export:
    {"business":{"name":"business","label":"Businesses","singular_label":"Business","description":"","public":"true","show_ui":"true","has_archive":"true","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","supports":["title","revisions","thumbnail","page-attributes"],"taxonomies":[],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit":"","edit_item":"","new_item":"","view":"","view_item":"","search_items":"","not_found":"","not_found_in_trash":"","parent":""},"custom_supports":""}}

    And the Tax:
    {"product-category":{"name":"product-category","label":"Product Categories","singular_label":"Product Category","hierarchical":"true","show_ui":"true","query_var":"true","query_var_slug":"","rewrite":"true","rewrite_slug":"","rewrite_withfront":"1","rewrite_hierarchical":"0","show_admin_column":"false","labels":{"menu_name":"","all_items":"","edit_item":"","view_item":"","update_item":"","add_new_item":"","new_item_name":"","parent_item":"","parent_item_colon":"","search_items":"","popular_items":"","separate_items_with_commas":"","add_or_remove_items":"","choose_from_most_used":"","not_found":""},"object_types":["business"]}}

    I have other CPT and Taxes as well.

    My only thoughts are that something is blocking the command somehow. I’m calling it in my extras.php file of the Roots Lib folder.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not having any issue removing the metabox here. So the 2nd example above works and is what you need.

    I’m wondering if the extras.php file is being loaded at all, though logically it should be.

    Have you tried placing it in your functions.php file temporarily as a test?

    Thread Starter aaronrobb

    (@aaronrobb)

    Michael

    Found the problem. Yes, had something to do with some code above this breaking in the extras.php file.

    Should have thought of that a while ago.

    Just for note, I am using the second example above, with two different meta boxes two slugs ($slug2), and it works great now!

    Thanks for the help!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Removing Meta Box of Custom Taxonomy in CPT’ is closed to new replies.