If you look at WordPress’ available query variables, you will notice post_type
. You will need to add that to your URL:
$terms = get_the_terms( $post->ID , 'category' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'category' );
if( is_wp_error( $term_link ) )
continue;
$term_link = add_query_arg(
array(
'post_type' => $post->post_type
),
$term_link
);
echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}
Reference:
https://developer.wordpress.org/reference/functions/add_query_arg/
Related Posts:
- How to get all taxonomies of a post type?
- Permalinks: custom post type -> custom taxonomy -> post
- How to Add Tags to Custom Post Type?
- Mixing custom post type and taxonomy rewrite structures?
- Efficient Taxonomy Intersection
- Set relationship between custom_post_types
- Remove admin menu for custom taxonomy attached to custom post type
- How do I list custom taxonomy terms without the links?
- Page not found taxonomy custom post type
- How to list custom taxonomy categories?
- clients list using wordpress
- Custom taxonomy query for a custom post type
- Extend walker class with custom post types [closed]
- How to do a custom bookmarks post type?
- Custom permalinks – post type – hierarchical taxonomy’s
- Taxonomy posts on Archive page
- Taxonomy list. Order by a specific custom post type count
- Rewrite CPT slug with two taxonomy slug instead of one
- How to display Custom Taxonomy of Custom post type
- Custom content type meta_box_cb does not run
- associate custom post type with tags with specific pages
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Custom Taxonomy breaking pages permalinks
- taxonomy template for custom post type the same as the archive
- Get categories and descriptions from custom post type
- Custom Post Types for Support Ticket plugin?
- Problem with custom post types, taxonomy and permalinks
- How to create new category for custom post type?
- Repeating posts when paginating random posts
- Query/list all terms and their custom post count
- Remove url rewrites for registered taxonomies
- Received nothing after executing AJAX post function
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Get custom taxonomies from multiple posts
- How can I make a custom post type sticky?
- Mapping Subdomains in WordPress to give the appearance of a localised site, best approach?
- Get Taxonomy Term Title by it’s URL
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Group CPT posts by custom taxonomy
- Limit number of custom posts per taxonomy
- Number of Custom Post Types published are not being shown in the custom page
- Metabox not show in categories custom post type cmb2
- Categorize custom post type
- Load Custom_post_type categories post with ajax
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- WP-API select custom taxonomy when creating a post
- List of Posts and Categories
- Why is my WP_Query outputting my entries twice?
- How to display Related Posts based on number of taxonomy terms matched
- How to solve this custom post type goes to 404 page?
- Get term name without a foreach loop
- How to Set Taxonomy Object Description?
- Custom Post Type with Custom Taxonomy as Category
- WP_Query() with custom post type and taxonomy — get all terms?
- Add term list as class
- Taxonomy archive 404ing (not term archive)
- How do I get the custom category URL from the custom post type?
- Alphabetically sort a taxonomy.php template by post title
- Custom post type name and assigning custom taxonomy
- get_terms() parent, child and grandchild
- Get posts by category name
- List child categories from parent category on custom taxonomy page
- Grab all Custom Posts by multiple taxonomies and terms
- Create a custom taxonomy template that loops through child categories in term order?
- Custom Post Types and Complex Content Hierarchy
- If custom taxonomy else conditional [closed]
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- How to implement very unusual wordpress routing structure?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- How to display custom taxonomy term specific post?
- Changing permalink of default Post with custom post
- get_queried_object not work in taxonomy page
- wp_insert_post deleting previous post custom meta
- Custom Taxonomy Archive generates 404
- Change custom post taxonomy values from front-end
- Pages of my taxonomy terms are showing all posts
- How to create a permalink structure with custom taxonomies and custom post types
- Support for author does not show author column in post table in dashboard
- Is there a way to re-order the Custom Taxonomy drop-down on a Custom Post listing page?
- How to get all posts related to a taxonomy?
- Custom post types not displaying per category
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Force WordPress to only match URL in category
- Hierarchical taxonomy in permalink structure
- Can I create a taxonomy term that mirrors the name of a new custom post?
- Rewrite for custom type and custom taxonomy
- How to create TEMPLATES for TAXONOMIES? What I have to change in this code?
- Custom Post Status & Taxonomies
- Displaying taxonomy icon outside archive page
- Why won’t this rewrite rule work?
- Archive.php is not displaying tags
- How to not have the items of the subtaxonomy within the parent taxonomy
- How to save an integer as taxonomy term?
- Sort custom post type items by taxonomy description
- Tags and Taxonomy links not working for Custom Post Types
- how do I create a breadcrumb to work with multiple custom taxonomies
- Get custom post type parent category
- How can i change url structure of cpt like this?
- Custom Post Type urls not working
- Show a wordpress custom post condtionally using a category term