How do you display event in one city with posterboard layout? And how do you list cities with events?
Thanks!
Jukka Varis
You can’t display a posterboard for a city, but you can display a posterboard with filters for the city:
[event_board filters="city"]
To display a list of cities:
<?php
$cities = eo_get_venue_cities();
if( $cities ){
echo '<ul>';
foreach( $cities as $city ){
echo '<li>' . esc_html( $city ) . '</li>';
}
echo '</ul>';
}
Stephen Harris
Yeah, i’m aware of that filter option. Anyway, is it possible (yet) to have links on this city list that it will filter events to the specific city somehow? Or is there way to do that filtering on reverse (when i click on city it displays only that)?
Jukka Varis
Reversing the behaviour of the posterboard filtering is on the roadmap.
But you can implement the city-specific posterboard yourself with a few lines of coded added to a utility plugin or theme’s functions.php:
add_action( 'pre_get_posts', function( $query ){
if( $query->get( 'my_event_venue_city' ) ){
$query->set( 'venue_query', array(
array(
'key' => '_city',
'value' => $query->get( 'my_event_venue_city' )
)
) );
}
}, 5 );
This snippet uses an anonymous function for brevity – so you may wish to change that if you’re running php 5.2.
Then you can use it as follows: [event_board my_event_venue_city={city name}]
Note that the city name must be identical to as it appears in the venue admin page
-
This reply was modified 9 years, 8 months ago by Stephen Harris.
Stephen Harris
Hi, I have a problem w/ city with two names…
eg. “San Diego”
if I write [event_board my_event_venue_state=San Diego]
no search results ;(
Mario P.
Try
[event_board my_event_venue_state="San Diego"]
Stephen Harris
It’s OK !! thank you very much !!
Mario P.
(can you change my name in forum “Mario Pellicardi” to “Mario P.”)
😉
Mario P.
Done. I see you can’t change that yourself, I shall make sure that’s addressed.
Stephen Harris
I use the same code to display events from a specific country:
add_action( 'pre_get_posts', function( $query ){
if( $query->get( 'my_event_venue_country' ) ){
$query->set( 'venue_query', array(
array(
'key' => '_country',
'value' => $query->get( 'my_event_venue_country' )
)
) );
}
}, 5 );
which works well.
On top of this, I tried to add filter : city which is not working:
[event_board event_category=”fairs” my_event_venue_country=”Germany” filters=”city”]
Is there a fix for this?
Adnan Akbas
This works for me:
[event_board event_category="fairs" my_event_venue_country="Germany" filters="city"]
Please note the "
, you have ”
Stephen Harris
Hi Stephen,
this displays hundred of cities in all countries. For this specific page, I only need to filter cities in Germany.
Adnan Akbas