I would like to implement 2 or more different event list views.
For (this) example, say one to show a list of events in a category in the main content area, and in a sidebar show brief details of the next upcoming (single) event in a category.
So in the main content area and sidebar respectively I use:
[ESPRESSO_EVENTS category_identifier=”my-event-cat” sort=”DESC”]
and
[ESPRESSO_EVENTS category_identifier=”my-event-cat” sort=”DESC” limit=”1″]
The template content-espresso_events.php has been copied into the child theme twice and modified to give 2 views:
wp-content/themes/my-child-theme/content-espresso_events-list.php
and
wp-content/themes/my-child-theme/content-espresso_events-next.php
These I can load from the events template file, wp-content/themes/my-child-theme/loop-espresso_events.php, using
espresso_get_template_part( ‘content’, ‘espresso_events-list’ );
and
espresso_get_template_part( ‘content’, ‘espresso_events-latest’ );
All ok so far. My question is how can I determine which to load? How can I determine when loop-espresso_events.php is running in the main content area and when running in the sidebar? Or perhaps I should be having multiple versions of loop-espresso_events.php instead and ‘splitting further up the chain’
I’d like to have available such functions such as “is_sidebar()” or “template_name()”.
Forgive my terminology, I’ve been a Windows developer my working life and not yet devoted the time to really understanding WordPress development inside out – I appreciate this is probably a WordPress Development issue rather than EE4 specifically.
I can advise using get_sidebar(); to load in your custom sidebar. You’ll can make this happen using a page template or in archive-espresso_events.php.
Along with that, here’s little tip on making things simple so you don’t end up making a bunch of templates that include different shortcodes for each category: You can load up the native category archive by going to yoursite.com/event-category/your-category-name. This view will typically use the archive.php template from your theme, but it will first check for archive-espresso_events.php and before that it will check for taxonomy-espresso_event_categories.php.
Viewing 1 reply thread
The support post ‘Implementing Multiple Event Templates’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.