Recurring Events – List View – Showing Outdated Events

Home Forums Calendar Products Events Calendar PRO Recurring Events – List View – Showing Outdated Events

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #951952
    Mike Ruman
    Participant

    Hi –

    On my Upcoming Events tab (http://missionhillsdev.org/new/) the recurring events are showing past dates of the event. Any idea on how to just show the upcoming date of the recurring event?

    #952007
    Matthew
    Member

    Howdy mrhiking!

    I took a peek at your Upcoming Events tab and I’m going to try to help you get to the bottom of this 🙂 Just so that I have the full picture of what is going on, can you tell me a little bit about that Upcoming Events tab?  I don’t want to start throwing ideas around if they aren’t any use to you!

    1. Are you leveraging the Events List widget to power the Upcoming Events tab?
    2. Can you share the snippet of code that outputs the date for that event?

    With that info, we should be able to start to get rolling on finding a solution to that date problem!

    #952155
    Mike Ruman
    Participant

    I appreciate the help.

    I didn’t code this, another developer did. But, here’s his code for this.

    <ul class="events tab" id="events">
    			<header class="events"><h2>Upcoming Events</h2></header>
    
    			<?php
    				$args = array(
    					'post_type' => 'tribe_events',
    					'posts_per_page' => 10,
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'tribe_events_cat',
    							'field' => 'id',
    							'terms' => 13
    						)
    					)
    				);
    			?>
    			<?php $event_archive_query = new WP_Query($args);
    				while ($event_archive_query->have_posts()) : $event_archive_query->the_post(); $event = null; ?>
    					<li>
    						<div class="event">
    							<?php
    								if ( is_null( $event ) ) {
    									global $post;
    									$event = $post;
    								}
    								if ( is_numeric( $event ) ) {
    									$event = get_post($event);
    								}
    								echo '<div class="date-meta"><span class="date-month">';
    								echo tribe_get_end_date($event, false, 'M');
    								echo '</span><span class="date-day">';
    								echo tribe_get_end_date($event, false, 'd');
    								echo '</span></div>';
    							?>
    							<div class="event-details">
    								<a href="<?php the_permalink(); ?>"><p><?php the_title(); ?></p></a>
    								<p class="time"><?php echo tribe_get_start_date($event, false, 'h:i A'); ?> <span class="pipe">|</span> <?php echo tribe_get_venue() ?></p>
    								<a class="details-button" href="<?php the_permalink(); ?>">Details</a>
    							</div>
    
    						</div>
    					</li>
    				<?php endwhile; ?>
    				<div class="pull-right" style="margin-right: 15px; margin-top: 15px; clear: both;"><a href="<?php bloginfo('url') ?>/events" class="button">View Full Events Calendar</a></div>
    		</ul><!-- .events -->
    #952222
    Matthew
    Member

    Thank you for sharing that snippet – I believe it holds the key to the issue!

    The WP_Query call doesn’t appear to take the dates of the events into account. I think we can make that event fetching a bit simpler with a function call that is provided by The Events Calendar. Check out tribe_get_events() – which is basically an ultra fancy event-compatible WP_Query! You should be able to grab the posts that you are expecting using the following:

    
    $events = tribe_get_events( array(
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'tribe_events_cat',
    			'field' => 'id',
    			'terms' => 13
    		),
    	),
    ) );
    

    $events will then contain an array of post objects that you can loop over! Let me know how it goes!

    #952249
    Mike Ruman
    Participant

    Thanks for the response, Matthew!

    Do I replace that whole snippet of code with this (tried that, didn’t work). Or, where do I put this?

    Thanks!
    – Mike

    #952313
    Matthew
    Member

    No problem! 🙂

    That little snippet of code just gives you an array of events and, as you indicated from your tests, it won’t replace the whole block of code. It will, however, allow you to simplify some things! Since the provided code is fairly custom, I hesitate to detail out changes as I wouldn’t want to make assumptions that were inappropriate to your use case. That being said, I can point you to a few things that may be of use as you rework the code!

    • print_r can be used to see what information is returned by the snippet that I provided. Try print_r( $events );
    • Rather than the “while” loop that is in place in the code, I would suggest using foreach.
    • If you do go with foreach, you shouldn’t need to do the $event = null; that I see in the block of code.

    I hope this points you in the right direction!

    #955676
    Matthew
    Member

    It has been a while since the last time that I heard back from you so I hope that means everything is working well! 🙂 I am going to go ahead an close this thread, but if you have any further questions, don’t hesitate to open a new one!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Recurring Events – List View – Showing Outdated Events’ is closed to new replies.