The main problem is that, in your $_POST
loop, $value
is an array, yet you apply htmlspecialchars
to it, which will vomit and return back nothing.
If you haven’t done so already, set WP_DEBUG
to true
in your wp-config.php
– developing without it is simply not an option.
Regardless, let’s fix that dirty $_POST
loop:
$tax_query = array(); // Don't need relation "AND", it's the default
foreach ( get_object_taxonomies( 'recipe' ) as $tax ) {
if ( isset( $_POST[ $tax ] ) ) {
$tax_query[] = array(
'taxonomy' => $tax,
'terms' => wp_unslash( ( array ) $_POST[ $tax ] ),
'field' => 'slug',
);
}
}
$args['tax_query'] = $tax_query;
Related Posts:
- Why is my WP_Query not working when tax_query terms are an array?
- How to add terms to my tax_query based off of the current post
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- Function get_queried_object() return NULL in custom taxonomy
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Automatically Query Parent Taxonomy
- Taxonomy order exception for specific term
- Custom taxonomy.php not working
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- How to add custom meta to ‘pre_get_terms’?
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- Can’t get term id for category archive
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Only show tag with the same id as the post
- Save queried result into database
- wp_query with meta_query and tax_query
- WordPress – Form does not filter the results of taxonomies
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- taxquery taxonomy get terms
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- Taxonomy Terms That Don’t Exist Display Results
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Show posts without term
- Search custom taxonomy term by name
- How to display post from current Taxonomy in archive page?
- Modify Term Update Redirection
- Display posts the match taxonomy term linked from wp_list_categoies?
- WP_query taxonomy + get all posts with two terms from same taxonomy
- Pagination not working for Custom search form & custom result template
- SQL Statement generated by WP_Query not producing expected results
- Custom archive page based on array of categories and tags
- Display certain amount of posts on taxonomy archive page
- WP_Query with many meta_query arguments taking a long time to load
- List taxonomy terms plus their latest post ordered by post date
- Using AJAX to return search form results
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Advanced Tax Query
- List all custom post type posts from a given category?
- get complex results set according to category structure
- Filtering posts by custom field value not working
- Order taxonomy terms in alphabetical order
- Empty tax_query array returns an empty array
- How do I search inside specific taxonomies in WordPress
- Query Custom Post Type Order By Taxonomy Field
- Get taxonomy terms only of the WP_Query current posts
- Shortcode to show thumbnail and link for 3 random posts
- Changing stylesheet depending on custom taxonomy terms
- Output an array of terms for a ‘tax_query’ => array()
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- WP Query Args – Title or Taxonomy Value
- Slow queries on a huge database
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- Combining categories (Query posts with multiple taxonomy terms)
- wp_query args adding muitiple tax_querys
- How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?
- WP_Query for a taxonomy with different taxonomy types
- get term id from term name
- Get Child Category only
- How to print term name inside wp post loop
- Get posts in taxonomy randomly
- Using WP_Query for categories instead of get_terms
- Grabbing taxonomy terms and inserting them into an array
- Tax_Query using WP_Query not working
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Custom taxonomy in WP_Query not working
- Use get_cat_ID to retreive multiple category IDs
- WordPress Ajax form filter | Search by title with ajax form, breaks the other filters
- display ACF repater field in archive page
- How to use the Term Object from a custom select field in a query
- Display Custom Post Type Based on Taxonomy With WP_Query()
- Get categories within specific term
- whether a nonce is required for get type and get_query_var?
- WP_Query paginate with one term per page?
- pages shortcode filtering by category
- Combine Tax Archive and Meta_Query in WP_Query
- Get taxonomy url, name, post count & image
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- Category Archive not working for pages
- How can I get all the posts that are related with a specific taxonomy term?
- WP Query with sticky posts and tax_query
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Search format not matching taxonomy query
- Add a custom variable to query page object
- List posts of terms but exclude one term
- WP_Query on “property” in the options table
- Passing values by form to create a query
- Can One Taxonomies Terms be Ordered by A Seperate Taxonomy?
- Output ACF field dynamicaly within a taxonomy loop [closed]
- tax_query not working properly with get_posts
- query only direct child and sub-terms of a current term archive
- Get access to all terms associated to each post that the wp_query loop displays