Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When editing categories for my custom post type the selected admin menu is the one for posts (see screenshot). Is this a bug. If not it's kind of non intuitive, and not so good for the end users experience.

Screenshot

Code:

function product_register_product_post_type() {

    $box_post_type_args = array(
        'show_ui' => true,
        'public' => true,
        'taxonomies' => array(
            'product_category'
        ),
        'supports' => array(
            'title',
            'editor',
            'thumbnail',
            'slug'
        ),
        'labels' => array(
            'name' => 'Products',
            'singular_name' => 'Product',
            'add_new' => 'Add New Product',
            'add_new_item' => 'Add New Product',
            'edit_item' => 'Edit Product',
            'new_item' => 'New Product',
            'view_item' => 'View Product',
            'search_items' => 'Search Products',
            'not_found' => 'No Products Found',
            'not_found_in_trash' => 'No Products Found In Trash'
        ),
        'capability_type' => 'page',
        'rewrite' => array( 'slug' => 'produkt' )
    );

    register_post_type( 'product', $box_post_type_args );

    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        'name' => _x( 'Categories', 'taxonomy general name' ),
        'singular_name' => _x( 'Category', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Category' ),
        '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 Genre Category' ),
        'menu_name' => __( 'Categories' ),
    );  

    register_taxonomy( 'product_category', array( 'product' ), array(
        'public' => true,
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'produkter' ),
    ));
}
add_action( 'init', 'product_register_product_post_type');
share|improve this question
    
i do not think that wordpress supports custom categories just custom taxonomy and post types. I am sure there is a way to do custom categories but unfortunately i do not know how. It also might require a lot of coding –  xLRDxREVENGEx May 13 '11 at 16:04
    
It works now. With the code posted above. –  Joakim May 15 '11 at 10:31

2 Answers 2

You need to set up a custom taxonomy and then add the name of the custom tax via the "taxonomies" arg when registering the custom post type.

share|improve this answer
    
I've done that. But the selected admin menu when I click my custom taxonomy is still "Categories" under posts. –  Joakim May 14 '11 at 12:24
    
How about posting your code? I'm not good at guessing... –  kaiser May 14 '11 at 12:46
    
(: Posted above. –  Joakim May 14 '11 at 14:22
    
Try moving the tax registration above the custom post type. –  kaiser May 14 '11 at 14:36

Perhaps because you named your custom taxonomy "Categories"?

// Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        'name' => _x( 'Categories', 'taxonomy general name' ),
        // ...

...

register_taxonomy( 'product_category', array( 'product' ), array(
        // ...
        'labels' => $labels,

Try changing the values in your $labels array that you pass to register_taxonomy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.