Try following codes:
$country_search_array = array();
while($row = mysql_fetch_array($regionresult)){
$country_search_array[] = $row['country']; // Your country field name
}
$country_search = "'".implode("',", $country_search_array)."'";
$args = array(
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'Country',
'value' => $country_search,
'compare' => 'IN'
)
)
);
$query = new WP_Query( $args );
Related Posts:
- WP Meta Query for some meta (array) values
- meta_query with array as value
- Adding an array from a query string to a WP meta_query
- Multiple meta query from array
- meta_query returning excluded result
- Trouble with serialized metadata
- WP_User_Query Orderby Not Working
- Sort Posts with custom meta key by default which is currently set as optional
- How do I have multiple metaqueries inside one wordpress query
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- Add indexing to meta_value in wp_postmeta
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Custom WP_Query order by post_meta and (author) user_meta
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- How do I create my own nested meta_query using posts_where / posts_join?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Exclude post on loop by multiple meta key value
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- meta_key and meta_value not working together
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- Order WP Query posts by custom order calculated from post meta values
- Meta query with order by another custom field
- How to query for custom field within Gutenberg block from outside of that post? [closed]
- Can an array be used as a meta_query value?
- How can I get an array of all IDs from the current queried object?
- Meta query with JSON value
- Get meta info related to current post
- Creating arguments from loop for WP_Query meta_query
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Get attachment by meta_key value
- Using meta_query with multiple keys and compare values
- Why isn’t my `meta_query` array functioning properly?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Suggestions on making this query/code more performant
- Is it possible to set specific posts to show first in a query?
- Order by meta value (numeric value lower to higher)
- Large AND OR query timing out
- WP_Query with different postmeta filter for each categories
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Meta Query doesn’t works as espected
- Advanced WP_Query with meta_query, orderby?
- Issues with search after added meta_query
- Display posts with specific value first in query
- it’s possible make a WP_Query with math operations?
- Sorting search results with custom dropdown
- WP_Query: apply an SQL function to meta fileld value
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- query post by author gender
- Related Posts Excluding Certain Categories
- How do I add an item to the WP admin menu?
- WP_Query with 4 post meta field arguments gives 500 internal server error
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Custom meta_query order for Elementor based on post meta key [closed]
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- ElasticPress is (aparently) messing with my search filters
- Meta query ignores multiple values of the key
- Multiple meta_query not returning rows
- Check for not NULL not working in meta query
- What code to use in an array to call the current sub-category?
- Get unique post by meta value using wp_query
- Query against multiple locations within single custom post type post
- WP_Query, ACF field and array
- Order by Date Custom Field
- WP Query. Ordering posts by another post types meta
- Complex Meta Query
- Get posts meta_query by repater field
- Query 3 meta_key and orderby
- wp_query sorting – one specific meta_key value at last and then sort by create date
- Saving custom fields for WP_Query to retrieve
- meta_query not working with the_content()
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Get closest event where meta_key field is an array
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- How to sort a WP_Query array by post_name after an array_merge();
- Orderby Meta Value and Query from Meta Query
- WordPress WP_Query Array Custom search via taxonomies
- Set right order for query that returns posts based on two custom fields
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Meta_query weird behaviour
- WordPress extremely slow when using get_posts with multiple meta_query relations
- I want to place a post before all others from an ACF boleen field
- wp_query, calculate with two dates when ‘key’ is text format
- Use value from meta key array for use in WP_Query