• niel

    (@nielfernandez)


    Hi,
    How can I category box or meta box on this section
    Reference: https://www.awesomescreenshot.com/image/36880635?key=ac88146dfe5f5d67bac1df8f9e7ebfc3
    I already have a code added in my custom post type also appears in the dashboard admin.
    Reference: https://www.awesomescreenshot.com/image/36880422?key=a574e66a7d830e33a0f55f2ac6575f06

    My codes:

    add_action( 'init', 'create_blog_taxonomies', 0 );
    function create_blog_taxonomies() {
        $labels = array(
            'name'              => _x( 'Categories', 'taxonomy general name' ),
            'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
            'search_items'      => __( 'Search Categories' ),
            'all_items'         => __( 'All Categories' ),
            'parent_item'       => __( 'Parent Category' ),
            'parent_item_colon' => __( 'Parent Category:' ),
            'edit_item'         => __( 'Edit Category' ),
            'update_item'       => __( 'Update Category' ),
            'add_new_item'      => __( 'Add New Category' ),
            'new_item_name'     => __( 'New Category Name' ),
            'menu_name'         => __( 'Categories' ),
        );
    
        $args = array(
            'hierarchical'      => true, // Set this to 'false' for non-hierarchical taxonomy (like tags)
            'labels'            => $labels,
            'show_ui'           => true,
            'show_admin_column' => true,
            'query_var'         => true,
    		'show_in_quick_edit'  => false,
            'rewrite'           => array( 'slug' => __( 'blog-category', 'blog' ) ),
    		
        );
    
        register_taxonomy( 'blog-category', array( 'blog' ), $args );
    
    }

    That codes work with my custom post type however the box or meta box where I can add a category in a post not showing on adding a post like this
    Reference: https://loom.com/i/a1eb766ca9034df0a626cc6b3f78b944

    Thanks in advance!

    • This topic was modified 1 year, 8 months ago by niel. Reason: remove unnecessary link
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Is your ‘blog’ post type already registered when you register blog-category? If not, the taxonomy registration will not relate to the post. Naturally one always will come before the other. Whichever is second is where the relationship should be established. You can also establish a relationship after both are registered with register_taxonomy_for_object_type()

    It could be your code is all fine and the only problem is the category panel in the editor is just hidden from view. Check your editor screen preferences through the 3 dot icon at upper right. Click Preferences, then Panels and ensure your category panel is switched on.

Viewing 1 replies (of 1 total)
  • The topic ‘Category Box in Custom post type’ is closed to new replies.