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.

I have posts and I have recipes. Recipes is a custom post type. Recipes make use of the category taxonomy and a newly added recipe has been categorized under beer. When I browse the listing page for the category beer I see all my previous posts categorized under beer while the new recipe does not appear.

How do I link custom post types through their taxonomies? Or, how can I show all post types under a single category?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can use pre_get_posts hook to add your custom post type to the query

function include_recipes( $query ) {
    if ( $query->is_category ) {
        $query->set( 'post_type', array('post','recipes') );
    }
    return $query;
}
add_filter( 'pre_get_posts', 'include_recipes' );
share|improve this answer
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.