Let say you have “book” post type and “genre” taxonomy.
And you want to get books with genre of “scifi”.
You can pass the parameter in the url using:
?taxonomy=genre&term=scifi
Then you can get those parameter using get_query_var('taxonomy')
and get_query_var('term')
and add them to the WP_Query arguments.
$taxonomy = get_query_var('taxonomy');
$term = get_query_var('term');
$args = array(
'post_type' => 'book',
'tax_query' => array(
array(
'field' => 'slug',
'taxonomy' => $taxonomy,
'terms' => $term,
)
),
);
$query = new WP_Query($args);
Related Posts:
- custom taxonomy archive by year
- Custom Post Type Archive Page Filtering
- Advanced archive url structure (category, tag and date)
- Custom category taxonomy – archive page not showing up
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- Create template for taxonomy results limited by Custom Post Type
- wp_list_categories() – current-cat class also inside posts?
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- How to edit this code to get the categories in achieve page?
- Hierarchy and access control for Custom Post Types (CPT)
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- Custom post type / taxonomy rewrite archive page 2 gives 404
- browse by category and tags?
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- List of Posts and Categories
- How can I get this request to use the Custom Post Type page template instead?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Archive for a Taxonomy of a Custom Post type
- WP the_posts() on single-cars.php get category link
- in_category for custom post types
- What’s the name of the custom post type yearly archive template?
- Get parent category id from child category page for custom taxonomy
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- Custom Post type & Taxonomy 404
- How to add current custom taxonomy slug to body class
- Taxonomy archive 404ing (not term archive)
- List Posts By Custom Taxonomy
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Disable custom taxonomy on admin bar
- Why does my taxonomy have a category style div id?
- Targeting categories in custom fields
- Custom taxonomy or custom page templates?
- Dynamically insert an article at the top of a taxonomy archive – or?
- Listing all slugs?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- category list with cutom post count
- The Difference Between Categories and Tags and Taxonomies and Terms
- Include custom post type custom taxonomies in Categories widget
- Use the custom post type archive for taxonomies?
- Custom Post Type Categories URL not displaying posts
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Custom post type categories gives 404 error
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- get_terms() parent, child and grandchild
- Get child categories of custom taxonomy category?
- Custom Post Type Custom Archive Page Not Working
- List child categories from parent category on custom taxonomy page
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Archive page for custom post type and custom taxonomy
- Get terms for a specfic post from multiple taxonomies in custom post type
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Archive Template being used instead of Category Template for Custom Post Type
- Custom post not appearing under custom taxonomy category
- Menu’s breaking, now showing all page links on site
- Retrieve Custom Taxonomies with Description and Slug
- Custom post type category permalinks and archive pages
- Custom post type specific category box
- Custom Taxonomy Taxonomies of Same Name point to first created URL
- how to organize my categories or should I do custom post types for some?
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- How can I tell if I’m on a custom post type archive page?
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- How to divide Subcategories into pages of parent category wordpress
- Display all Categories except ones with a specific parent
- Custom front-end form for adding post – Category problem
- How to show related posts of category on post within custom posttype
- Custom Post Type Archive Page showing as 404
- How to display custom taxonomy term specific post?
- How to set “section categories”?
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Create custom post type categories
- Custom WordPress theme not displaying posts from category
- Show Custom Post Type based on Category on Archive Page
- How to show custom post count in archive page
- Set a Default CPT taxonomy by taxonomy id
- Order archive custom posts by taxonomy term [duplicate]
- How to manage a dynamic multi-level page hierearchy system?
- Categories manage
- Adding Custom Post Types to category/tag/author archives breaks header content
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Help with Travel Guide Setup
- Custom taxonomy archive slug overwrites static page
- Custom post types not displaying per category
- Custom post type category archive URL redirects to home page