Use calendar list view for custom event categories

Home Forums Calendar Products Events Calendar PRO Use calendar list view for custom event categories

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1214830
    Maximilian
    Participant

    Hello,

    happy new years to all of you.
    I’m working on a site right now that uses a number of additional custom categories / taxonomies on events that get registered via register_taxonomy. When viewing them the events get listed just fine but it would be great to use the the events calendar list view to display them instead of normal wp posts without meta, dates etc.

    The event category that already exists by default can use the list view. Is it possible to extend this to custom categories in some way? There are a lot of categories so I can’t just make a bunch of page templates for every single one.

    Thanks!

    #1214832
    Maximilian
    Participant

    I managed a way to somehow force the list view into a taxonomy template with this:

    
    <?php get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    		<?php get_template_part( 'tribe-events/list' ); ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php
    get_sidebar();
    get_footer();
    ?>
    

    This kinda(?) works but pagination breaks. Is there a way to get this to work more nicely?

    edit: welp, no way to unmark this as correct answer I guess

    #1214888
    Maximilian
    Participant

    Sorry for the triple post but I noticed one more obvious thing.
    Forcing the template in like I posted before works partially but of course apart from the pagination breaking the event order isn’t working either. It shows the event not in chronological event order but in the order they got posted via WP.

    The ideal solution would make it possible to use the event list view for my taxonomy template and also show normal posts that share the taxonomy.
    If its just about the events I guess you could modify taxonomy templates to use the tribe_get_events() function? Don’t know exactly how that would work though or how I could insert other post types on top of that.

    #1214913
    Maximilian
    Participant

    I now got the sorting to work by modifying the query meta_key and orderby like this:

    
    function customize_customtaxonomy_archive_display ( $query ) {
    	if (($query->is_main_query()) && (is_tax( array('zielgruppe', 'autor') ))) {
    		$query->set( 'meta_key', '_EventStartDate' );
    		$query->set( 'orderby', '_EventStartDate' );
    		$query->set( 'order', 'ASC' );
    		$query->set( 'posts_per_page', -1 );
    	}
    }
    

    This wouldn’t work on the normal posts that get mixed in between because they don’t have any _EventStartDate. So I added it on save_post for non-events. It uses the post creation date.

    So far so good. I can correctly query the events and posts I want and even sort them. Even if the _EventStartDate field for normal posts is kinda hacked I guess.

    Now there are two problems left:
    1. There are some the event calendar wrappers and scripts etc missing because I’m just pulling the list template in. Is there a more proper way to do this? Is there a way to fix pagination or should I leave it out?
    2. Is this future proof or hacked in a way that it might break with the next bigger update?

    Sorry again for posting so much, thanks for reading!

    #1215599
    Cliff
    Member

    Hi, Maximilian.

    Thanks for your detailed question and the updates. I’m glad you’re making progress with your customization.

    You can see how our plugin uses register_taxonomy, here: https://github.com/moderntribe/the-events-calendar/blob/4.3.5/src/Tribe/Main.php#L1473-L1508

    Maybe that will help.

    If you still need assistance, please clarify:

    1. It sounds like you do NOT want to display non-Event posts. Is this correct?
    2. If yes, why not just use Event Categories, that gets registered for you?

    You could utilize PRO’s Additional Fields to create a radio, checkbox, drop-down, or other type of “Region” field.

    Then Filter Bar could enable filtering by these regions. You could edit Filter Bar’s settings at wp-admin > Events > Settings > Filter Bar tab

    They wouldn’t be true “taxonomies”, but you could use them for such categorization and directly link to them, like this (but it’s filtering Venues, not a PRO Additional Field because we don’t have that setup on our demo site): http://wpshindig.com/events/list/?tribe_venues=29433

    Looking forward to hearing back from you…

    #1226913
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Use calendar list view for custom event categories’ is closed to new replies.