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.

Is there a way to use regular categories with custom post types? It seems like there is better functionality and options with regular categories (such as permalink options, etc.).

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

No problem, the categories and tags are also registered as taxonomies that you can pass to the taxonomies argument when you call register_post_type(). Categories are category and tags are post_tag. You can also do this later with register_taxonomy_for_object_type():

add_action( 'init', 'wpse6098_init', 100 ); // 100 so the post type has been registered
function wpse6098_init()
{
    register_taxonomy_for_object_type( 'category', 'your_custom_post_type' );
}
share|improve this answer
    
Sweet!! Works perfectly. Thanks a bunch! –  David Dec 29 '10 at 21:20
    
Is there an easy way to get the custom post type posts to show up in filtering results, too? –  Rasmus Sep 5 '12 at 22:19
    
@Rasmus: Do you mean on the category pages? Like /category/banana/, do you want to see regular posts and your custom post types mixed together? I think you need to hook into the query parameters and add your custom post type to the post_type parameter. But it has been a while since I used WordPress, it's not in my active memory now :-) –  Jan Fabry Sep 6 '12 at 7:12
    
Yep, that's exactly what I wanted. My reason is that otherwise it might be a little hard finding those posts. If someone has the answer in active memory, it would be appreciated -- until then, I'll make do with my (not pretty) work-around! –  Rasmus Sep 7 '12 at 8:07
add comment

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.