tags & categories with custom post type

What do i need to do to enable categories and tags for a custom post type i´ve made? I use the following code:

/* Create custom post type: "Tilbud" */
register_post_type('tilbud', array(
'label' => __('Tilbud'),
'singular_label' => __('Tilbud'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'supports' => array('title')
));

3 Answers
3

change your code to this:

/* Create custom post type: "Tilbud" */
register_post_type('tilbud', array(
'label' => __('Tilbud'),
'singular_label' => __('Tilbud'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'taxonomies' => array('post_tag','category'),
'supports' => array('title')
));

the function register_post_type takes a name of the post type and an array of arguments
one of these is “taxonomies” and that is what you are missing.

Leave a Comment