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
- List terms from Custom Taxonomy
- Custom Taxonomy breaking pages permalinks
- WP_Query search posts by custom post type and custom taxonomy
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- How to filter out post type meta?
- How to output wordpress custom tags separated by comma?
- 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
- Custom query to filter posts that have current post as a taxonomy [closed]
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- 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?
- Genesis filterable portfolio isotope [closed]
- Loading custom content type from ajax results?
- How can I see a list of my Custom Post Types of the last term I was in?
- Get custom post type list for every category shortcode
- Displaying custom taxonomy in the admin list of a custom post type
- Categories of custom taxonomy don’t show any posts
- AJAX load more for different custom post type loops
- Ajax Custom Post Filter is not filtering
- WordPress sort search results by custom order
- How to filter wp_list_categories output with some custom post type meta query?
- How to Filter custom post type by taxonomy?
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Filter term taxonomy metabox in custom post type
- creat filter with wp_query
- How can I made custom taxonomies relationship?
- Categorize custom post type
- Sort and filter custom post type posts by custom taxonomy
- Foreach loop returning more than one item when querying taxonomy
- 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?
- Custom post type page with parameter
- 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
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- set object terms after some some time of published post – functions.php
- update custom taxonomy custom fields
- Filter taxonomy by CPT
- Get all post under custom post type grouped by custom filed value in custom taxonomy
- Not saving custom taxonomy while using ajax
- Check that a slug is present in the get_terms request
- Assigning categories to custom post types via a front-end form; only works for native post type
- 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
- How to display custom post type pagination buttons when processing AJAX request
- Filter Custom Post Type Posts by Taxonomy
- Change Search display for Custom Post Type
- Show parent category and subcategory once in while loop
- Custom search for a custom post type in WordPress
- Show ajax form resuslts in page
- tax_query not working?
- Add active class to foundation 6 tabs while looping categories
- The most recent post of custom taxonomy
- Show tags of custom post types in WordPress
- WordPress query posts by custom post type not workng
- Show custom taxonomy not in submenu
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- 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
- How to Fix WordPress 500 Internal server error due to custom post type
- Dropdown switching subcategories portfolio
- Values inside a custom field to determine which category posts to display
- 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?
- Building a List of Posts grouped by custom taxonomy as the section header only to be displayed if at least one post is in that tax
- posting twice from an array?
- Custom Loop for custom post type. Compare by meta_value?
- update custom taxonomy with Ajax in edit.php file [duplicate]
- 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