• Hi there! I’m new in wordpress and i’m lovin it, i also really appreciate the-events-calendar plugin. A feature i was missing was to use different templates to show events depending on the event’s category. Finally i managed it in a very simple way, but i had to edit a core class of the plugin.
    In /wp-content/plugins/the-events-calendar/ i edited the-events-calendar.class.php i changed the lines 430-438
    from

    global $wp_query;
    $this->constructDaysOfWeek();
    // list view
    if ( $this->in_event_category() && ( events_displaying_upcoming() || events_displaying_past() ) ) {
    	if( '' == locate_template( array( 'events/list.php' ), true ) ) {
    		load_template( dirname( __FILE__ ) . '/views/list.php' );
    	}
    	exit;
    }

    to

    global $wp_query;
    
    $tecCatObject = get_category( $wp_query->query_vars['cat']);
    
    $this->constructDaysOfWeek();
    // list view
    if ( $this->in_event_category() && ( events_displaying_upcoming() || events_displaying_past() ) ) {
    	if( '' == locate_template( array( 'events/list-'.$tecCatObject->slug.'.php' ), true ) ) {
    		if( '' == locate_template( array( 'events/list.php' ), true ) ) {
    			load_template( dirname( __FILE__ ) . '/views/list.php' );
    		}
    	}
    	exit;
    }

    this way now i’m able to use a different listing template based on the category of events i’m viewing.
    I hope it could be helpfull for someone but I’d be even happier if it could be a feature in a next release..
    one love
    gio

Viewing 8 replies - 1 through 8 (of 8 total)
  • Will this allow the categories to display separate calendars?

    Thats what I really need… we have an events calendar which uses separate cities as categories, and we absolutely need the ability to display the categories and upcoming events as separate calendars.

    Thread Starter jahnni

    (@jahnni)

    I’m not sure i fully understood what your desired result is.
    Maybe the solution to your problem is even easier than the one described above, have you tried to set the Events category as parent of your cities category (every city as child of Events category)?
    I used the solution I’ve described above ’cause I had to display different event categories with different layouts. That’d be your case if you need to show the events in different way for every city. i.e.: you want to show the events titles for a city, a picture and the date for another city and so on….

    Worked perfectly!

    I edited this post because we screwed up the slug for the post. Calendar becomes https://culturecoma.com/category/events-montreal/

    Thanks so much for your help!

    Whoops, the pretty URLs got that, and it is actually now https://culturecoma.com/category/montreal/

    Sweet!

    I think this has been updated in a new version of The Events Calendar because the-events-calendar.class.php no longer references the code above. It’s too bad too because I’ve been looking for a solution for this very problem for almost 2 hours now. Any thoughts? Is there any way to assign a category template to an event category? I’ve tried the normal wordpress way but no luck. Please help ??

    Katzw, have you checked whether any of the current documentation (https://tri.be/support/documentation) could help you out with this?

    Hi Roblagatta: I have tried, but I think I’m not proficient enough in wordpress functions to understand what I need to do? I posted elsewhere in the forums with the code:

    <?php the_content(); ?>
    <?php query_posts( array('post_type' => 'tribe_events', 'post_name' => 'my-events-category-name'));?>
    <?php endwhile; ?>

    However, someone has also just replied with the following code:
    ‘<?php $my_query = new WP_Query(array (‘post_type’ => array( ‘Your Category Name Here’, ‘tribe_events’ ) ) );
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate[] = $post->ID ?>’

    Which I will try now and if it works I’ll post again to let others know ??

    katzw,

    That doesn’t work, haven’t found anything useful yet.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: The Events Calendar] Event category template’ is closed to new replies.