Home Forums General Issues Taxonomy Link to Custom Post Type Archive Reply To: Taxonomy Link to Custom Post Type Archive

  • Hi @dniclas

    You say you’ve also registered a custom taxonomy connected with your portfolio-cpt but to me it seems you’ve rather created a term/category named art only. That means that when visiting the archive you’re visiting the archive of a regular category (wordpress builtin categories).

    If you want to only display your custom post type you’ll have to hook into the query for this archive and change the post_type OR actually register your own taxonomy and use that instead.

    Here’s a snippet you can add to your themes functions.php to change the archive of the specific “art” category to only display your CPT:

    function my_modify_queries( $query ) {
    	//dont run on admin or not a main query
        if ( is_admin() || ! $query->is_main_query() )
        if ( is_category('art') ) {
            // Display only 1 post for the original blog archive
            $query->set( 'post_type', 'portfolio-cpt' );
    add_action( 'pre_get_posts', 'my_modify_queries', 1 );