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