WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

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
up vote 1 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
    
Nothing else worked except this solution. Thanks A lot!!1 – Farzad YZ Feb 6 at 11:59

Your Answer

 
discard

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