WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some custom post type but I want to add categories for it. Not for the URL(-structure) but for an archive page, which shows every category after each other. So the items are organized. Anyway to do this or isn't this possible?

share|improve this question

If you want to use builtin WordPress categories, while calling register_post_type function with taxonomies parameter set to category

If you want to create a custom category, then use register_taxonomy function to register a brand new taxonomy with second parameter to be your custom post type name and pass it taxonomy name to register_post_type as explained above.

A sample would look something like this

$args = array(
    'label' => __( 'Book' ),
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'book' ),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'taxonomies' => array('language'),
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )

            'label' => __( 'Language' ),
            'rewrite' => array( 'slug' => 'language' ),
            'hierarchical' => true,
  register_post_type( 'book', $args );
share|improve this answer
Anyway to get the category? $categories = get_categories($cat_args); just gets the normal post categories. – Disgeae Jul 26 '13 at 10:55
Yes, get_terms( 'language', 'orderby=count&hide_empty=0' ); if you meant category by your custom taxonomy. – M-R Jul 26 '13 at 11:00
And last one: posting the name? :) – Disgeae Jul 26 '13 at 11:01
I dont get what you mean by "posting the name". p.s You should be searching a little bit before asking on SO. – M-R Jul 26 '13 at 11:08

Your Answer


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.