You can achive this using WP Query
with meta_query
argument as following.
$args = array (
'post_type' => array( 'post' ), // YOUR POST TYPE
'meta_query' => array(
array(
'key' => 'country',
'value' => $your_country, // THE COUNTRY TO SEARCH
'compare' => 'LIKE', // TO SEARCH THIS COUNTRY IN YOUR COMMA SEPERATED STRING
'type' => 'CHAR',
),
),
);
// The Query
$query = new WP_Query( $args );
I have tested this query. Working perfect. Hope this might work for you as well.
Edit:
For multiple countries you can use following approach.
$countries_to_search = 'usa,africa,poland'; // YOUR COMMA SEPARATED STRING
$countries = explode( ',', $countries_to_search ); // CONVERT INTO ARRAY OF COUNTRIES
$meta_array = array();
$meta_array['relation'] = 'AND'; // DECLARE RELATION --> YOU CAN USE 'OR' AS WELL
foreach($countries as $country){ // CREATE QUERY FOR EACH COUNTRY IN ARRAY
$meta_array[] = array(
'key' => 'country',
'value' => $country, // THE COUNTRY TO SEARCH
'compare' => 'LIKE', // TO SEARCH THIS COUNTRY IN YOUR COMMA SEPERATED STRING
'type' => 'CHAR',
);
}
$args = array (
'post_type' => array( 'post' ), // YOUR POST TYPE
'meta_query' => $meta_array, // ARRAY CONTAINING META QUERY
);
// The Query
$query = new WP_Query( $args );