WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. derekshirk
    Member
    Posted 1 year ago #

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

    <div class="widget">
    		<ul>
    
    			<?php
    
    			global $post;
    				$all_events = tribe_get_events(
    				array(
    					'eventDisplay'=>'upcoming',
    					'posts_per_page'=>10,
    					'tax_query'=> array(
    				array(
    					'taxonomy' => 'tribe_events_cat',
    					'field' => 'slug',
    					'terms' => 'willow-creek-events'
    					)
    					)
    				)
    			);
    
    			foreach($all_events as $post) {
    			setup_postdata($post);
    			?>
    
    			<li>
    
    			<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>
    			<br/>
    
    			<em><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></em>
    
    			</li>
    
    			<?php } //endforeach ?>
    			<?php wp_reset_query(); ?>
    		</ul>
    
    					<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>
    					</div>
    		</div>

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

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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:

    http://snippi.com/s/y0wu903

    Cheers,

  4. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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:
    http://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts

    Cheers,
    Jonah

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic