I have a Taxonomy called Cities. I have created a custom field for this taxonomy, using ACF, called Country So I can create a City and select the Country (select list with predefined options) it belongs to in the dashboard.
I then create my Post, and select a City it belongs to. (ie Paris)
On front end, I have created a drop down list from the value of the ACF custom field which works fine, like this
$field_key = "field_1234564545445";
$field = get_field_object($field_key);
if( $field )
{
echo '<select name="country">';
echo '<option value="">Choose Country</option>';
foreach( $field['choices'] as $k => $v )
{
echo '<option value="' . $k . '">' . $v . '</option>';
}
echo '</select>';
}
This gives me a list of the Country used by the Taxonomy Cities. So I get a list like France, Italy, Spain etc. No I am trying to query my post type using one of these country, but I can't manage to get a result.
$args = array(
'posts_per_page' => '12',
'post_type' => 'ARTICLES',
'orderby' => 'date',
'order' => ASC,
'meta_query' => array(
array(
'key' => 'country',//Also tried field_1234564545445
'compare' => '=',
'value' => $country,
),
),
'paged' => $paged,
);
Will appreciate a pointer thx