I have a search page with filter country so that users can select to search upcoming events in a specific country.
[event_search filters=”country”]
If there is no more an upcoming event for a country, this country still exists in the filter drop-down list.
It would be nice not to see this country if there is no more events there.
Is this a setting issue?
Adnan Akbas
Hi Adnan,
No, the countries are listed even when there’s not future events in that country. This is the same as with the other filters.
Stephen Harris
Hi Stephen,
Do you have a hint for me, how I can remove these countries from the dropdown list if there is no event for this country?
Thanks in advance,
Adnan
Adnan Akbas
The code is in line 267 of includes/shortcode.php – essentially you would need to iterate over every country in $countries
and query for events in that country. If there are none, then skip it.
An example query would be:
$future_uk_events = eo_get_events( array(
'venue_query' => array(
array(
'key' => '_country',
'value' => 'UK'
)
),
'event_start_after' => 'today'
));
(see http://docs.wp-event-organiser.com/querying-events/getting-events-via-venue-queries/)
But this is not particular performant, as you are doing a query for each country
Stephen Harris
Hi Stephen,
I am not really a fan of changing core files therefore I will leave the countries in the dropdown list for now.
Thank you for your support.
Adnan Akbas