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.

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')
));
share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
The categories and tags still don´t show up. Is there anyting else i need to do? –  user1635 Jan 18 '11 at 12:10
    
even with the taxonomies attribute?? –  Bainternet Jan 18 '11 at 12:59
    
yes, even using the code you suggested. –  user1635 Jan 18 '11 at 15:28
add comment
up vote 0 down vote accepted

It worked when I added the following code:

function add_tags_categories() {
register_taxonomy_for_object_type('category', 'tilbud');
register_taxonomy_for_object_type('post_tag', 'tilbud');
}
add_action('init', 'add_tags_categories');
share|improve this answer
add comment

Your Answer

 
discard

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