Skip to content

Display Custom Post type in Category Archive Page

We can easily add taxonomies to custom post types by defining taxonomies Parameters while registering custom post types like this:

/* 'taxonomies'=> An array of taxonomy identifiers */
'taxonomies'         => [ 'category', 'post_tag' ]

This also adds the option to select a category and tag in the backend (wp-admin).

However, By default WordPress custom post types do not appear in a category or tag archive page.

To include the custom post type in the category or tag archive page, add below filter on your plugin or themes functions.php. This modifies the query for the default taxonomy archive page.

function show_post_type_in_cateogry( $query ) {
if( is_category() || is_tag() && empty($query->query_vars['suppress_filters'] ) ) {
    $query->set( 'post_type',['post','your-custom-post']);
    return $query;
add_filter( 'pre_get_posts', 'show_post_type_in_cateogry' );