Add ‘relation’ => ‘OR’ to your Meta Query, I think it will be something like this…
'meta_query' => array(
'relation' => 'AND', // Optional, defaults to "AND"
array(
'key' => $country_meta_key,
'value' => $country,
'compare' => 'LIKE'
),
array(
'relation' => 'OR',
array(
'key' => $state_meta_key,
'value' => $us_state,
'compare' => 'LIKE'
),
array(
'key' => $state_meta_key,
'value' => $ca_state,
'compare' => 'LIKE'
),
array(
'key' => $state_meta_key,
'value' => $mx_state,
'compare' => 'LIKE'
)
)
);
Related Posts:
- get_posts( $args ) return empty data
- get posts meta query returning the latest post if no meta key found
- Sorting not working with get_posts
- How to do a meta query using REST-API in WordPress 4.7+?
- Get result from meta_query() between two numbers
- Using meta_query on pre_get_posts to exclude a particular meta_key value
- Archives for custom post type based on a “date” meta value
- get_users meta_query
- meta_query with multiple values
- Return posts with specific meta key first, but the rest in alpha order by last name
- meta_query key value from array
- Order by nested named meta queries with ‘exists’ and ‘not exists’
- Arrange Posts By Date In Order Of Closest To The Current Date
- Using get_terms() with meta_query parameters
- WP_User_Query with meta_query array relation ‘OR’
- Loop through two different sets of custom fields
- meta_query problem
- Custom Upcoming Events List for Events Manager Plugin
- meta_query date and time comparisons
- How to exlude posts that have certain meta_value?
- User Relationship
- WordPress Core – Optimizing meta_query generated SQL?
- Edit post_content on posts with Featured Image
- Display no post when metavalue is 0
- Use both meta query and tax query
- meta_query, number comparison, not quite working as it should
- Meta Query Compare with Date
- Does meta_query working with value paramater higher then 999?
- meta_query keys and sticky posts
- Meta query: get posts with value in a multidimensional array
- Fastest way to do meta query when I don’t need the actual posts, and just need post_id?
- How to query post only with different excerpt?
- Stuck in Order by more then one
- Get posts with multiple meta values
- WP User Query Issues
- How to use meta query for greater than value in array?
- Wp Query custom search by meta query
- Filter posts by meta query?
- Help on multiple meta_query
- pre_get_posts and set
- How to use orderby with meta_query?
- meta_query: check if number exists
- I would like to have add_post_meta to return the ID instead of true or false
- last_name + first_name orderby with meta_query [solved]
- Check if searched number is within the post meta value
- how to get post meta where value is an array of key value pairs
- Meta Query Based on Month Range
- Find posts by related taxonomy field
- wordpress meta value compare between two date
- Can I use pre_get_posts to add up values from two different meta_keys?
- WP JSON API meta_query not working
- get_users with Serialized Custom Meta Value
- Sorting posts by ACF field
- Get all posts with a certain meta key, except for one with specific title
- Ordering custom posts by meta field date
- latitude/longitude meta_query
- meta_query displays all results and none, my query is wrong
- How to properly escape values in meta query
- How to add date_query to meta_query array
- Delete all posts with a specific custom field using meta_query
- Fetch custom post related to a User
- Use meta_query in args for relationship
- meta_query Array
- meta_query compare “=“ returns nothing when it seems it should
- Order resultset by configured value and then list all the rest
- Issue with user meta_query
- How to get an archive page meta?
- Search for value(s) in meta field for a multi select
- Querying terms with calculations based on term meta data, sql vs. get_terms
- How can I create a meta_query with an array of dates?
- WordPress meta query not working
- Get meta_value from GDRating
- How to count items of meta query?
- WordPress meta query with meta serialized data array value
- wordpress meta query with multiple meta condition causing a load on server and slows down the server..!
- Why does this incorrect pre_get_posts meta_query work for sort order?
- How to sort custom posts including null meta-values in admin columns with meta_query?
- Memory Leak in Processing Large JSON file
- meta_query not filering but meta_key works fine
- WordPress search between two newmeric values with a custom post type
- like_escape notice when using LIKE in meta query
- meta_query for user ID in array
- Display query post based on two orderby value in wordpress
- WP User Query with meta queries
- Using get_posts, I need to use a combination of OR & AND relations
- WP_Query with UNIX timestamp in meta query
- Querying by meta key and value
- How to compare date in post meta value
- Which Meta Query Compare Method Should I use?
- Sort posts by post views and consider meta key
- Meta query “OR” comparison not working as expected with array
- How to output meta_key in wp_postmeta?
- Get_term with meta_query
- WordPress Meta Query very slow with NOT EXISTS comparison
- WordPress extremely slow when using get_posts with multiple meta_query relations
- ACF meta_query field treated as “0” resulting in false negative search when testing ranges
- Is it possible to customize meta query in this way?
- Ordering WP_Query results by second meta_key
- How making a new search box in admin post table working on a specific column
- wp_user_query with meta_value_num for leaderboard