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.

I have created a custom taxonomy and configured it to work like a category. The taxonomy shows up fine on the admin, but when I create a post, it is then placed in the default uncategorized category. I'm not sure why this is happening.

Am I doing something wrong? Any suggestion?

My function is:

function register_taxonomy_test() {

$labels = array( 
    'name' => _x( 'test', 'test' ),
    'singular_name' => _x( 'test', 'test' ),
    'search_items' => _x( 'Search test', 'test' ),
    'popular_items' => _x( 'Popular test', 'test' ),
    'all_items' => _x( 'All test', 'test' ),
    'parent_item' => _x( 'Parent test', 'test' ),
    'parent_item_colon' => _x( 'Parent test:', 'test' ),
    'edit_item' => _x( 'Edit test', 'test' ),
    'update_item' => _x( 'Update test', 'test' ),
    'add_new_item' => _x( 'Add New test', 'test' ),
    'new_item_name' => _x( 'New test', 'test' ),
    'separate_items_with_commas' => _x( 'Separate test with commas', 'test' ),
    'add_or_remove_items' => _x( 'Add or remove test', 'test' ),
    'choose_from_most_used' => _x( 'Choose from the most used test', 'test' ),
    'menu_name' => _x( 'test', 'test' ),
);

$args = array( 
    'labels' => $labels,
    'public' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'show_tagcloud' => false,
    'show_admin_column' => true,
    'hierarchical' => true,

    'rewrite' => array( 
        'slug' => 'little', 
        'with_front' => true,
        'hierarchical' => true
    ),
    'query_var' => true
);

register_taxonomy( 'test', array('post'), $args );
};

EDIT:

@Charles - yes I have added the code below sorry/. forgot to mention it here.

add_action( 'init', 'register_taxonomy_test' );

@OTTO - it shows up in the uncategorized "category" even after I make sure I have checked on a custom taxomony I created

EDIT #2

Ok so I decided to go with regular categories and not custom taxonomies. For any one interested why a new post with custom taxomony defaults to un-categorized, is because it is linked to the post type which is "post". So you must also enable a custom post type "register_post_type()" that is linked to your custom taxonomies that will act as categories.

share|improve this question
    
First you have at the end of your code a Semicolon for whatever reason(delete it!), secondly you don't have any action hook? Add following code on next line at the end: add_action( 'init', 'register_taxonomy_test', 0 ); –  Charles Mar 25 at 9:43
1  
Custom Taxonomies don't replace categories, they are separate. Do you mean that it shows up in the uncategorized "category", or as uncategorized in your custom taxonomy? –  Otto Mar 25 at 10:21
    
thanks for the reply! it shows up in the uncategorized "category" even after I make sure I have checked on a custom taxomony I created –  bheku Mar 25 at 14:16

1 Answer 1

Ok so I decided to go with regular categories and not custom taxonomies. For any one interested why a new post with custom taxomony defaults to un-categorized, is because it is linked to the post type which is "post". So you must also enable a custom post type "register_post_type()" that is linked to your custom taxonomies that will act as categories.

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.