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
- Display all the subcategories from a specific category?
- tax_query in get_posts() not working?
- How to get_term_children output in alphabetical order?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- Correct use of get_the_terms()
- I have a term_taxonomy_id — is there an API call to get the taxonomy?
- array_pop() expects array, boolean given for $event_type_term ->slug
- Get_term_by only returns one item from array
- How to update incorrect post count in taxonomy?
- Term begins with a letter
- tax_query not working on main query
- 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
- 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 post terms for multiple posts at once?
- wp_update_term: How could i update the “name”?
- WP_Tax_Query with post_tag not working
- Check if an array of posts has posts from a specific category
- Sort a custom post type array numerically
- Get only one product category woocommerce
- Check if term object is in array
- get_terms() order by term_meta
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- What is the term shortlink structure?
- Invalid argument supplied for foreach() in search.php
- How do I determine if a certain term is in an array?
- ‘wp’ action hook not firing in admin and login?
- get_terms ‘number’ parameter does not appear to work
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Question with get_the_term_list
- Use pre_get_posts to sort meta_key by an array of values
- Custom post taxonomies as tax_query terms?
- Create / Close Div in Array [closed]
- import_id parameter for wp_insert_term to create custom ID for category
- Why does wp_get_object_terms add a period after terms are output?
- How to apply comma separation,strip_tags and orderby to wp_get_object_terms
- wp_set_object_terms not working inside loop
- Leveled – Terms foreach
- Add Taxonomy Description with wp_set_post_terms
- get_the_terms() not returning expected result
- How can I access string value in an array?
- Add class to first post queried
- wp_insert_post() does not support variable
- Missing term_id value
- Get the ID of category page with or without any posts
- WordPress Term for Custom List
- array_replace throwing php_warning but working anyway
- How do I print a term list but alter the link text?
- Override tax_query with pre_get_posts to include other term_ids on a single category
- Polylang : Display term archive even if no posts
- Get category if used in a custom post type
- Echo term slug op post on archive page
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Display posts belonging to child term
- Create alphabetical Pagination for custom taxonomy?
- Get get_terms alphabetically
- How to get term by name with parent id?
- CTP – check for value inside objects
- If product is in sub-category show code
- List posts by their custom taxonomy term, with a condition
- Set unique term_id from custom meta keys
- Trying to use wp_set_object_terms while supplying an array for both term id, and texonomies
- Exclude post type with pre_get_posts?
- Problem retriving the post type category
- get_terms_args ordering by meta key not working
- Cannot retrieve categories for post in The Loop
- Sort query_terms_list for post_tags alphabetically
- wp_set_object_terms doesn’t work
- get_the_term_list( get_the_ID() label formatting?
- I can get posts in all categories. But I want to get the custom post type I created
- How to display taxonomy order child, parent
- wp_get_post_terms – Do Not list Duplicates
- Flush rewrite rules after a term is edited
- How to show term child only if has a post
- wp_set_object_terms not accepting variable array
- Wrap custom terms loop
- WP_Query: Meta_Query with serialized value (or a workaround)
- A Comma Between Each Items Except the Last One with get_the_term_list [duplicate]
- get_terms not working when child_of is used
- modify strip_tags function to use term slug instead of term name
- pre_get_posts main_query not displaying after applying tax_query filters
- get_terms Parent Tags
- Get term_taxonomy_id from return of wp_insert_post
- Function to delete a term when a custom post with the same slug is trashed
- Get object terms with no children?
- How do I assign a custom post to all terms in a custom taxonomy?
- Conditional output based on taxonomy ID of custom post
- is action hook not working on quick edit?
- list taxonomy terms in current post / current category
- Relate term to term?
- How can I filter get_terms with post meta
- Unable to import term_meta in wordpress using wp_cron
- How can I replace the values in WP_Term?