Home › Forums › Calendar Products › Events Calendar PRO › Create category archive list on one page
- This topic has 3 replies, 2 voices, and was last updated 13 years, 5 months ago by
Jonah.
-
AuthorPosts
-
October 22, 2012 at 12:21 am #26942
Star
ParticipantHi –
I’m hoping to use the category pages as an archive, with the page listing the following data, in this order:
Category Description
Upcoming events in this category
Previous events in this category– all on one page. What’s the best way to go about doing this? I couldn’t quite figure out how I might edit list.php to make this happen.
Thanks,
StarOctober 22, 2012 at 5:52 pm #27014Jonah
ParticipantHi Star,
This is a more complex customization question that I can’t spend the time on answering here but I can hopefully point you in the right direction. You would want to edit list.php because this ultimately controls the display of the list of events. So, first make a copy and place in an ‘events’ folder in your active theme. Now you make any changes to it and preserve the core file.
Basically what you’ll need to do then is check with a WordPress conditional tag whether or not you are viewing an event category and if you are, display details about that category. Event categories are technically taxonomies so the conditional tag you want to use is is_tax() (http://codex.wordpress.org/Function_Reference/is_tax) and then within that conditional tag you would place tags calling the category (taxonomy) description and then are you ok with the default upcoming/previous events display? If not, you’d need to replace the default list with some custom queries using tribe_get_events() or WP_Query
Here is a brief, stripped down example of the code you’d use to display the category description in list.php: https://www.sourcedrop.net/Iu45e9f8ce42d – place that wherever you’d like the description to display.
Does that help?
– Jonah
October 28, 2012 at 12:28 pm #27285Star
ParticipantI just realized there’s an easier way to describe this – is it possible to just list events in a category, including already past events, all in one stream available on the category page? IE, just like a regular blog category – so the past events don’t fall off to a separate “Previous events” page, they just get pushed down the stream as new events are added?
October 29, 2012 at 10:18 am #27317Jonah
ParticipantHi Star,
Sure, one way you could do this is to modify the query in a category so that x amount of posts are shown per page (or all posts on one page). To do this you would just add this bit
of code to your theme’s functions.php file:
//show all events on the events list pages when viewing an event category
add_action( 'pre_get_posts', 'show_all_events' );
function show_all_events( $query ) {
if ( $query->query_vars['eventDisplay'] == 'upcoming' || $query->query_vars['eventDisplay'] == 'past' && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set('posts_per_page', -1);
}
return $query;
}
Does that help?– Jonah
-
AuthorPosts
- The topic ‘Create category archive list on one page’ is closed to new replies.
