The Events Calendar
Custom Category Display Conditional Logic Help (5 posts)

  1. derekshirk
    Posted 4 years ago #

    I am using the following code to display a specific event category in one of my site's sidebars.

    <div class="widget">
    			global $post;
    				$all_events = tribe_get_events(
    					'tax_query'=> array(
    					'taxonomy' => 'tribe_events_cat',
    					'field' => 'slug',
    					'terms' => 'willow-creek-events'
    			foreach($all_events as $post) {
    			<span class="event-date" style="color:#666;"><a href="<?php the_permalink(); ?>"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></a></span>
    			<em><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></em>
    			<?php } //endforeach ?>
    			<?php wp_reset_query(); ?>
    					<div class="dig-in" style="font-family: Georgia, Times, serif; font-style: italic; text-transform: lowercase;
    		font-size: 12px; color:#ccc;">
    					<a href="http://bond.pcc.edu/dev/upcoming-events/category/cascade-events/">View all events</a>

    How could I use conditional If / Else logic to to display a default message if there is no event for the current category?


  2. Rob La Gatta
    Modern Tribe Support
    Plugin Author

    Posted 4 years ago #

    Hey derek. I'm not sure about the level of effort required for this (it may be fairly complex), but have asked our dev Jonah to take a look to see if he can point you in the right direction. No guarantees but if it's straightforward enough we will see what we can do.

    In the interim, if you haven't checked out our documentation at http://tri.be/support/documentation, you may find some information that is generally useful as you continue to use the plugin. Thanks for your support so far.

  3. derekshirk
    Posted 4 years ago #

    Thank you so much for the reply. I would love to get some feedback on your thoughts for the most efficient way of achieving this.

    In the meantime I worked up a solution that is working for me. You can check it out here:



  4. Rob La Gatta
    Modern Tribe Support
    Plugin Author

    Posted 4 years ago #

    Awesome to hear this solution did the trick. When Jonah takes a look (should be today sometime) I'll get him to comment as to the solution and whether it seems viable for the long term. Cheers!

  5. jonahcoyote
    Posted 4 years ago #

    Hey derekshirk,

    That's a perfectly valid chunk of code, the only thing I would change is using WP_Query instead of query_posts

    See this for an explanation:


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • The Events Calendar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic