Create category archive list on one page

Home Forums Calendar Products Events Calendar PRO Create category archive list on one page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26942
    Star
    Participant

    Hi –
    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,
    Star

    #27014
    Jonah
    Participant

    Hi 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

    #27285
    Star
    Participant

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

    #27317
    Jonah
    Participant

    Hi 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Create category archive list on one page’ is closed to new replies.