2

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?

2

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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.