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
- Why are posts from custom post type not displayed in “category” archive?
- Displaying category archive of custom post types
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How to filter custom post types by custom category taxonomy
- Create permalink structure for one taxonomy archive per custom post type
- remove support for ‘Categories’ for a custom post type
- Glossary with Custom Post Type
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Pages, Custom Posts & Custom Taxonomy defining slug structure
- How to show a tag archive of one post type only
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Regex problem in an add_rewrite_rule
- Custom taxonomy archive page not working
- Custom edit post column – category not showing
- How to show multiple post types on taxonomy archive?
- Disable single pages and archives and keep preview
- Custom post type taxonomy template
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Get post type from taxonomy or category page
- get_categories() for only CPT
- Category page only displaying the posts from a custom type
- Display custom post type taxonomies as an archive page
- Querying Term Posts in Loop
- Weird problem happening with custom taxonmy when creating/updating posts
- Insert HTML inside link in a walker
- Archive page for taxonomy terms
- CPT Archive with core Category
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- wp_list_categories() – current-cat class also inside posts?
- Show a Category X’s custom post type on Category X archive page?
- 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
- 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
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- in_category for custom post types
- Get parent category id from child category page for custom taxonomy
- Archieve.php not loading for custom post type
- Custom Post type & Taxonomy 404
- How to add current custom taxonomy slug to body class
- List Posts By Custom Taxonomy
- How to Display Posts From Category Within a Custom Taxonomy?
- Disable custom taxonomy on admin bar
- Dynamically insert an article at the top of a taxonomy archive – or?
- Listing all slugs?
- category list with cutom post count
- The Difference Between Categories and Tags and Taxonomies and Terms
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- Get child categories of custom taxonomy category?
- 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
- Custom post not appearing under custom taxonomy category
- 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 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
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Show Custom Post Type based on Category on Archive Page
- How to show custom post count in archive page
- 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 type category archive URL redirects to home page
- How can I generate a list of post-type specific categories?
- Display custom Taxonomies same as listing Categories
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Display 2nd category, only once, as sub-heading, in the loop
- archive.php can’t find categorized posts
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Get a list of categories ids
- How can I set up the URL for a category archive for a custom post type?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- Display a custom post type list by taxonomy term
- Return Custom Post Type Categories
- Remove slug from Custom Category Permalink + dual-category permalinks
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- How can I show second most recent post in sidebar, if most recent post is open in the browser?
- Show custom category archive as front page and remove taxonomy slug from urls
- How to add categories to a custom post type using wp_insert_post($new_post);