What I would like to do is, when the user unselects all the terms in the filter it displays all the posts of my Custom Posts Type.
In that case, then make the tax query optional:
// In mysite_filter_function(), define $args like so:
$tax_query = array( 'relation' => 'AND' );
if ( ! empty( $groups_terms ) ) {
$tax_query[] = array(
'taxonomy' => 'group',
'field' => 'slug',
'terms' => $groups_terms,
);
}
if ( ! empty( $teachers_terms ) ) {
$tax_query[] = array(
'taxonomy' => 'teacher',
'field' => 'slug',
'terms' => $teachers_terms,
);
}
$args = array(
'orderby' => 'date',
'post_type' => 'workshop',
'posts_per_page' => -1,
'tax_query' => $tax_query,
);
Related Posts:
- Ajax filter with custom taxonomies
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- Received nothing after executing AJAX post function
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Exclude Custom Post Type from shared Custom Taxonomy
- Saving Taxonomy Terms
- How to filter post data with AJAX on page?
- Help with issues on “Adding a Taxonomy Filter to Admin List for a Custom Post Type?”
- Get all taxonomies for all post types
- Show ACF field from custom taxonomy and display on the single template
- List terms from Custom Taxonomy
- WP_Query search posts by custom post type and custom taxonomy
- How to filter out post type meta?
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Weird problem happening with custom taxonmy when creating/updating posts
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Getting the URL of the parent page
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- get_posts of Custom Post Type AND Custom Taxonomy
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Get custom post type list for every category shortcode
- Displaying custom taxonomy in the admin list of a custom post type
- Ajax Custom Post Filter is not filtering
- WordPress sort search results by custom order
- How to Filter custom post type by taxonomy?
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Filter term taxonomy metabox in custom post type
- How can I made custom taxonomies relationship?
- Sort and filter custom post type posts by custom taxonomy
- search suggest – filter post type
- Different Category system needed for the Custom Post Type
- Retrieve custom post types by custom taxonomies with WP_Query
- Trying to get custom post of a custom taxonomy
- Control content before and after custom post type loop
- Ajax filter button display all posts
- How do I add custom HTML to the content of an archive page’s posts?
- Different options per post type in WP_Query
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- REST filters only firing when I have a param set
- filter by custom taxonomy using ajax
- Creating a non-hierarchical Taxonomy that behaves like categories
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Query custom post types & Taxonomies and list them in a table on a page
- Custom post type and custom taxonomy 404 on page 2
- Nested Custom Taxonomies | Incorrect posts when querying
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Function to erase every post from a taxonomy
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Using page title as a link to term archive
- Custom Taxonomy Filter Issues
- Setup page template array in a custom post type
- How do I ensure that post_type and Taxonomy use the same slug?
- How to get post count of specific taxonomy that have store name & category
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- Custom front-end form for adding post – Category problem
- set object terms after some some time of published post – functions.php
- update custom taxonomy custom fields
- Filter taxonomy by CPT
- Not saving custom taxonomy while using ajax
- Store a value in global scope after init hook is fired
- Filter in Custom post type to find the parent post
- pagination problem listing custom post types of taxonomy in wordpress
- Dynamic page for nav items used as filters
- Taxonomies are not showing in the category dropdown
- Combine multiple separate lists into one
- Filter Custom Post Type Posts by Taxonomy
- Change Search display for Custom Post Type
- Custom search for a custom post type in WordPress
- Show ajax form resuslts in page
- Insert custom taxonomy into category query
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- Custom Taxonomy – fields
- tax_query not working?
- Add active class to foundation 6 tabs while looping categories
- WordPress query posts by custom post type not workng
- Show custom taxonomy not in submenu
- Creating adminable dynamic filtering on custom post type
- Pods pagination erases my sub menu
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Dropdown switching subcategories portfolio
- Show Custom Post Type taxonomy term that matches custom field
- WordPress Custom Post Type and sort by Tags
- using ACF datepicker to filter posts on a page
- Order by custom field attribute
- Custom filtering on month value only of an entire date field
- Looping taxonomy in taxonomy?
- posting twice from an array?
- Custom Loop for custom post type. Compare by meta_value?
- Inserting two categories
- How do I filter a custom post type loop by a field?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- How do loop categories post from according in WordPress? is it impossible to solve this problem?
- How to filter custom post data with AJAX?
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template