I would like to be able to list upcoming events with the same formatting as is used for lists of events on category and venue pages, instead of in a plaintext list like the events list shortcode generates.
I made a custom page template and added the following but it doesn’t load anything and is broken somehow, because the page after this point doesn’t load.
<?php eo_get_template_part( 'eo-loop-events' ); //Lists the events ?>
I also tried modifying the events list shortcode to use the same line, and it shows the formatting but each event just says “Nothing Found. Apologies, but no results were found for the requested archive.”
I can’t tell where the list of events that the eo-loop-events
template uses is actually loaded.
How can I make a page for upcoming events that lists them like the events lists on the venue and category pages?
Emma Azelborn
Hi Emma,
The templates are intended for the ‘main loop’ of the page. You can trick WordPress into having multiple ‘main loops’ and then reset the query afterwards:
query_posts(array(
'post_type' => 'event',
//...
)); //not new WP_Query(), or eo_get_events()
eo_get_template_part( 'eo-loop-events' );
wp_reset_query();
It’s generally not recommended to do this though. So you may prefer to just create your own templates that don’t use the ‘main query’, but a WP_Query
instance.
Stephen Harris