Support » Plugin: Custom Post Type UI » Hide Meta Box when editing posts

  • Resolved Jon Fuller

    (@freshyjon)



    I want to keep the UI for a taxonomy in all views EXCEPT for when a user is in the custom post type, editing a post. I don’t want the meta box to show.

    Essentially it seems I need to set this to false meta_box_cb, but I don’t see an option for that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    Good day Jon.

    We have a UI field for meta_box_cb and taxonomies slated for 1.6.0, but that’s not ready yet.

    That said, you’re not out of luck by any means, as we have long had filters available for the registration arguments for cases where we don’t have UI spots for.

    The following code can easily be added to your theme’s functions.php file or if you’re a bit fancier, via a custom plugin. The snippet isn’t meant to be copy/pasted exactly, as I demo 2 different ways to handle things: either for all taxonomies, or conditionally by taxonomy slug.

    function jon_edit_taxonomy_args( $args, $tax_slug, $cptui_tax_args ) {
    
    	// Set to false for all taxonomies created with CPTUI.
    	$args['meta_box_cb'] = false;
    
    	// Alternatively, you can check for specific taxonomies.
    	if ( 'genre' === $tax_slug ) {
    		$args['meta_box_cb'] = false;
    	}
    
    	return $args;
    }
    add_filter( 'cptui_pre_register_taxonomy', 'jon_edit_taxonomy_args', 10, 3 );
    

    This snippet can be removed once 1.6.0 is out the door and you’ve used the new field at the time.

    Let me know if you need any help with this or have questions.

    Jon Fuller

    (@freshyjon)

    Excellent. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide Meta Box when editing posts’ is closed to new replies.