Just use:
'terms' => $rt_cat_id
I’ll work for both array and single-based values.
Or you can simplify your code as follows:
if( isset( $_GET[ 'listing_cat' ] ) ) {
$tax_query[] = array(
'taxonomy' => 'listing_category',
'field' => 'id',
'terms' => $_GET[ 'listing_cat' ]
);
}
Related Posts:
- How to Get All Taxonomies AND All Terms For Each Taxonomy With Post Count Zero
- PHP Warning: Attempt to read property “slug” on bool in tax query
- Tax query array terms display out of order
- WordPress emails error regarding the argument type even if the type is correct
- What is ‘term_group’ for ‘order_by’ in get_terms()?
- Order get_terms by term meta
- Display all the subcategories from a specific category?
- tax_query in get_posts() not working?
- Get parent id by term id
- How to get_term_children output in alphabetical order?
- When to / not to use wp_get_post_terms vs get_the_terms?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Why does WordPress combine a term with the same name in the wp_terms table?
- pre_get_posts with tax_query causes empty result
- Correct use of get_the_terms()
- Get multiple term IDs by slug, and then exclude them in get_terms
- wp_list_categories: order by term order?
- Child terms from multiple parents?
- I have a term_taxonomy_id — is there an API call to get the taxonomy?
- Exclude Child Terms From Parent Posts
- same taxonomy for several post types: how to hide empty in a specific post type?
- How to sort terms with diacritical signs?
- wp_set_object_terms creates relationship to REVISION?
- get_terms(); show private posts when logged in
- Get category ID after wp_insert_term
- Why is my WP_Query not working when tax_query terms are an array?
- get_terms with posts that have a different taxonomy with term x
- How do I access a single term from a post?
- Prevent Selected Terms Rising to the Top
- array_pop() expects array, boolean given for $event_type_term ->slug
- How to order get_term_children output by alphabetic order
- Get_term_by only returns one item from array
- How to update incorrect post count in taxonomy?
- Order posts by (hierarchical custom) taxonomy terms and term children
- Term begins with a letter
- get_post_terms not working as expected
- WP_insert_term how to insert multiple values as taxonomny term?
- Query set using tax_query with relation ‘OR’ modifies category object?
- tax_query not working on main query
- wp_update_term not creating new unique slug
- has_term() does not return when term is assigned post?
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Ordering Posts with Custom Taxonomy Terms Array
- get_terms() but with additional dimensions?
- Wp set post terms not work
- how is it possible that using wp_insert_category throw a fatal error?
- Get Term names from WP Term Object
- tax_query: What to pass when I want to have all terms?
- get_terms only show term if there is a post using it
- Get post terms for multiple posts at once?
- wp_update_term: How could i update the “name”?
- WP_Tax_Query with post_tag not working
- Get the Term List – Ordering
- Dynamically tax_query terms
- Reduce / optimize calling of wp_get_object_terms() when generating permalinks
- Check if an array of posts has posts from a specific category
- How to add terms to my tax_query based off of the current post
- Sort a custom post type array numerically
- Get only one product category woocommerce
- How to trace/fix false $term->count, rogue term relationships?
- Change default ordering of taxonomy terms – pre_get_terms
- How to order and count get_terms by specific post type?
- Outputting an array of term meta values in a custom WooCommerce tab?
- Get those terms with a specific meta key value
- How do I sort posts by custom taxonomy?
- Check if term object is in array
- get_terms() order by term_meta
- Variable in Array Not Working
- Empty tax_query array returns an empty array
- Difference between get_category, get_term_by and get_categories
- get_terms() for custom taxonomy related to another taxonomy
- pre_get_posts: using tax_query only for certain post type
- get_terms from registered taxonomies not working
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- pre_get_posts Remove tax_query Completely
- What is the term shortlink structure?
- get_term_by “name” not working with & in name
- I want to loop through Woocommerce Product Catogories and show them in dropdown
- Invalid argument supplied for foreach() in search.php
- setting taxonomy term to bulk posts using ids
- Do I have to set parent when set post term?
- How do I determine if a certain term is in an array?
- tax_query operator woes
- ‘wp’ action hook not firing in admin and login?
- Taxonomy archive showing no results
- How can I add multiple ‘tax_query’ arrays via a loop?
- Modify automatically generation of slug when term is created
- Display custom taxonomy on single post
- get_terms ‘number’ parameter does not appear to work
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- get_tags() return an empty array after added tags with wp_insert_term()
- Does get_terms() use any sort of caching on its query?
- Question with get_the_term_list
- Use pre_get_posts to sort meta_key by an array of values
- Group child category IDs based on their parent category
- 404 on term taxonomy archive pagination only with some terms
- get a simple array of all of the term names that exist in all taxonomies
- How to use $query->set with post__in?
- Clone Terms of one taxonomy to another