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() )
return;
if ( is_category('art') ) {
// Display only 1 post for the original blog archive
$query->set( 'post_type', 'portfolio-cpt' );
return;
}
}
add_action( 'pre_get_posts', 'my_modify_queries', 1 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.