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
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- WP query taxonomy input differs to output?
- Search custom taxonomy term by name
- Function in array as arguments for WP_Query
- WP_Query to show post from a category OR custom field
- Sorting posts by custom date fields (non standard date format)
- How to display post from current Taxonomy in archive page?
- Getting attachments by meta value
- Display posts the match taxonomy term linked from wp_list_categoies?
- meta_query where value is equal to given value
- Why is my WP_Query not working when tax_query terms are an array?
- 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
- Move posts to top of WP_Query if in certain Taxonomy?
- How to query using a combination of custom_field values?
- Sorting Posts by custom field
- Order posts by date and then by custom field
- Revolution Slider Orderby Two Custom Fields
- Querying Multiple Custom Taxonomy Terms
- Query two post types and order by two different date fields
- WordPress altering my custom query, How to fix it?
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Order by meta_key in custom post type doesn’t affect the query
- Filter and list posts of a custom taxonomy
- WP Query – Get WooCommerce Products with variation that is in stock
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- meta_key and meta_value not working together
- How can i make WP_Query return post image and categories?
- Custom Field sort not working (WP 3.8.1)
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- wp_query with multiple custom fields
- How to add terms to my tax_query based off of the current post
- How add a custom posttype name using ACF field to a query post array
- getting posts and number by specific meta value in multiple meta
- Ordering Posts Type A by Custom Fields of related Post Type B
- Order Posts by meta value AND published date
- Order taxonomy terms in alphabetical order
- Is it possible to dynamically get queried term AND taxonomy?
- WP Query for variable taxonomies
- How do I search inside specific taxonomies in WordPress
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- Search Posts with Custom Fields as query
- 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
- exclude posts with a specific custom field and value
- Getting Taxonomy inside WP_Query Loop
- Complex WP_Query (two post types and multiple operators)
- Add quicklink to in the Admin posts page where I can query by a meta_key
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- How to make Meta Query case sensitive?
- 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
- Remove category from query (show all posts in archive.php) pre_get_posts()
- is_tax() function not working as expected
- Advanced Taxonomy Queries WordPress
- Display Featured Post by Categories and Avoid duplicated posts
- Fetch Record based on meta key dates
- Meta_query with multiple keys and multiple values
- Get authors by term id or slug
- Orderby is working with one query but not with other
- meta_query BETWEEN, but the range is stored in the custom field
- WP_Query tax query part of slug
- Get a list of posts with associated meta_value
- Taxonomy Query Relation field not behaving correctly?
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- Extend product search with meta in WooCommerce
- WP Query Args – Title or Taxonomy Value
- How to list custom fields as headers and list all pages sharing that custom field under it?
- How to Union two different conditions in one WP_Query
- how to make members list directory through wordpress post custom meta key.
- Order by empty custom field
- Slow queries on a huge database
- Query posts without meta preload
- Adding multiple meta_key fields as orderby options to a WP Query via a function
- How do I exclude the lowest level terms in a taxonomy?
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- Large AND OR query timing out
- Post loop for all taxonomy terms
- meta_value_num not ordering all items
- wp_query args adding muitiple tax_querys
- Categorising search results based on Custom Fields
- Taxonomy and Date in same query?