Include custom post type in “all posts”

Filter pre_get_posts:

add_filter( 'pre_get_posts', 'wpse_98213_add_post_types_to_tax_query' );

/**
 * Let WP search for custom post types on taxonomy archives.
 *
 * @wp-hook pre_get_posts
 * @param   object $query
 * @return  object
 */
function wpse_98213_add_post_types_to_tax_query( $query )
{
    if ( ! is_main_query() or ! is_tax( 'your_taxonomy_name' ) )
        return $query;

    $query->set( 'post_type', array ( 'portfolio', 'post' ) );

    return $query;
}

More examples in our tag .

Leave a Comment