Display event in specific city

This topic contains 12 replies, has 4 voices, and was last updated by  Adnan Akbas 5 years, 5 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #16819

    How do you display event in one city with posterboard layout? And how do you list cities with events?

    Thanks!

    Jukka Varis
    #16822

    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
    #16826

    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
    #16862

    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 8 years, 11 months ago by  Stephen Harris.
    Stephen Harris
    #24504

    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.
    #24507

    Try

    [event_board my_event_venue_state="San Diego"]
    
    Stephen Harris
    #24548

    It’s OK !! thank you very much !!

    Mario P.
    #24549

    (can you change my name in forum “Mario Pellicardi” to “Mario P.”)
    😉

    Mario P.
    #24599

    Done. I see you can’t change that yourself, I shall make sure that’s addressed.

    Stephen Harris
    #24603

    OK ! thank you 😉

    Mario P.
    #32063

    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
    #32126

    This works for me:

     [event_board event_category="fairs" my_event_venue_country="Germany" filters="city"]
    

    Please note the ", you have

    Stephen Harris
    #32131

    Hi Stephen,

    this displays hundred of cities in all countries. For this specific page, I only need to filter cities in Germany.

    Adnan Akbas
Viewing 13 posts - 1 through 13 (of 13 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.