Your 'meta_query'
value is wrong – it should be:
'meta_query' => array(
array(
'key' => 'city',
'value' => $location,
'compare' => '=',
)
);
Anyway, you don’t need to use 'meta_query'
in this case where you have to filter by just one meta field… So for a little more optimized code, try replacing your $args
with the following:
$args = array(
'post_type' => 'location',
'tax_query' => array(
array(
'taxonomy' => 'specialties',
'field' => 'slug',
'terms' => $specialty,
)
),
'meta_key' => 'city',
'meta_value'=> $location,
);
Related Posts:
- Display link to taxonomy archive only if it has posts with certain custom field values
- Output an array of terms for a ‘tax_query’ => array()
- How to use the Term Object from a custom select field in a query
- Can wp_query return posts meta in a single request?
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- WP query taxonomy input differs to output?
- meta_query where value is equal to given value
- Get_post() with meta_key when compare is a date
- querying with custom meta field with meta_query
- Group posts by custom field
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- Revolution Slider Orderby Two Custom Fields
- WordPress altering my custom query, How to fix it?
- Order by meta_key in custom post type doesn’t affect the query
- Filter and list posts of a custom taxonomy
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- wp_query with multiple custom fields
- getting posts and number by specific meta value in multiple meta
- Order Posts by meta value AND published date
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- wp_query add arguments using array_push if variable met
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Group WP_Query by meta_key date
- How To Fix WP Query Returns Results But Shouldn’t?
- Order by slug in get_terms with multiple taxonomies
- Get posts for which a custom field is not present, with get_posts
- Function get_queried_object() return NULL in custom taxonomy
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- How to Filter Posts by Custom Fields?
- Display custom field meta outside loop, site wide
- is_tax() function not working as expected
- Advanced Taxonomy Queries WordPress
- Fetch Record based on meta key dates
- Orderby is working with one query but not with other
- Taxonomy Query Relation field not behaving correctly?
- Extend product search with meta in WooCommerce
- how to make members list directory through wordpress post custom meta key.
- Adding multiple meta_key fields as orderby options to a WP Query via a function
- meta_value_num not ordering all items
- Taxonomy and Date in same query?
- WP Group posts by year(desc) > month(desc) > date(asc)
- Redirect to another page using contact form 7? [closed]
- Using custom taxonomies in a query
- WP_Query Meta_key is text value and need to sort as numeric not working
- filter wp_query result with custom field values
- Order post type by sum of two custom fields
- Get Child Category only
- WP ForLoop to compare meta information of posts to determine what post to display
- How to echo woocommerce category name
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Order WP_Query results by meta key value in custom query
- WP Query – filtering terms with regex
- Querying a large number of posts including their custom fields data
- add_query_arg to compare and display events from a certain date
- relation OR instead of AND – Filtered term ID’s in loop
- Can’t get term id for category archive
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- Query ACF relationship field – Comparator IN – Value array
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- How do i create a custom post query when the meta value is an array?
- How to add a “base” filter for all posts visible to visitors on the site?
- Save queried result into database
- WP Query – grouping posts by same meta key, adding together values from another key
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- meta_query is overriding default search
- Comparing Meta Field date in WPQuery using Meta_Query?
- WP_Query paginate with one term per page?
- Order 2 meta_queries differently in WP_Query?
- using custom meta user data to run queries in WordPress
- Order posts by title and custom field value?
- How to create URL parameters to run custom queries?
- Taxonomy Terms That Don’t Exist Display Results
- List users by Year of Birth using a foreach loop to dynamically populate years and data
- Meta key in wp_query bug?
- Custom WP_query and integrating into theme file
- Wrap group of wp query posts to parent div by date/year
- Custom taxonomy and query multi conditions
- WP Query with sticky posts and tax_query
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Sorting posts by meta values: 2 different orders
- Sorting Posts with meta value not working
- Order by three custom fields (Y-m-d), then separate into yearly sections
- Loop through multiple custom fields with increasing number
- new WP_query using custom fields
- Get the tax term in which is a post via wp_query
- query post based on comparison
- tax_query not working properly with get_posts
- Get posts by meta value except one post [closed]
- Custom query for certain post type OR another post type with a certain category
- WP_Query sort by ACF date field (newest first) with blank dates first
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2