Event Search Confusion

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15504

    I am trying to figure out how to get the events/event page to display the event search form.

    I inserted this code below the header and got the events listing twice.

     <?php
            echo do_shortcode('[event_search filters="date,event_category,event_venue"]');
    ?>
    

    I realize that the shortcode includes both the filter form and the results. The question I now have is how to make each event appear only once.

    Howard Jacobson
    #15507

    Hi Howard,

    The event search shortcode was intended for use on a page rather than the events pages. The two lists will (in general) differ – the one generated by the shortcode will be the results of the search query, and the page list will be reflect the current page being selected.

    You could remove the while loop of the template you’ve edited (I’m assuming this is archive-events.php). However, that may have some adverse affects, e.g. if you click on a date in the widget calendar it will display all events running that day – if you remove the while loop and add the shortcode, it will just display all the events (or first 10 theoreof).

    The year and month pages also use that template. One way around this to ignore the shortcode when on year / month / day pages:

     if( eo_is_event_archive( 'year' ) || eo_is_event_archive( 'month' ) || eo_is_event_archive( 'day' ) ){
           //Year/month/day page: display default `while` loop
     }else{
           //Display event search shortcode instead
     }
    

    Please note that since the shortcode wasn’t intended for use on the event pages, it hasn’t been tested on them,

    Stephen Harris
    #15528

    Thanks, Stephen. Your responsiveness is terrific.

    OK, so I want the event search filter to appear at the top of all event listing pages. Users should be able to filter event lists no matter whether they are on the events/event page or the search listing page. Is this possible?

    Howard Jacobson
    #15552

    For filtering you could use the event categories/venues widgets and display these on the events pages. When viewing the events pages, clicking a particular category/venue will take them to that venue/category page.

    However for simultaneous filters, combined with search / date filters then you’ll need to use the event search shortcode. You can “turn off” the events page via:

    add_filter( 'eventorganiser_event_properties', 'my_configure_event_post_type' );
    function my_configure_event_post_type( $event_cpt ){
        $event_cpt['has_archive'] = false;
        return $event_cpt; 
    }
    

    and use the page with the event search shortcode as the events page.

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 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.