Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created August 22, 2012 16:38
Show Gist options
  • Save jo-snips/3427287 to your computer and use it in GitHub Desktop.
Save jo-snips/3427287 to your computer and use it in GitHub Desktop.
The Events Calendar: Custom Query for Past Events
<?php
global $post;
$get_posts = tribe_get_events(array('posts_per_page'=>-1, 'eventDisplay'=>'past') );
foreach($get_posts as $post) { setup_postdata($post);
?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="thumbList">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumbnail', array('class' => 'scale-with-grid attachment-thumbnail')); ?></a>
</div>
<div class="event-excerpt">
<h6 class="event-title"><span class="front-start-time"><?php echo tribe_get_start_date( $post->ID, false, 'Y M j g:i a' ); ?> </span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>
<?php the_excerpt(); ?>
</div>
<div class="clear"></div>
<?php } else { ?>
<h6 class="event-title"><span class="front-start-time"><?php echo tribe_get_start_date( $post->ID, false, 'Y M j g:i a' ); ?> </span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>
<div class="event-content">
<?php the_content(); ?>
</div>
<div class="clear"></div>
<?php } ?>
<?php } //endforeach ?>
<?php wp_reset_query(); ?>
@dunga-suresh
Copy link

Thank you so much!

@shivamgpt08
Copy link

Thanku so much it is working good

@Hermete
Copy link

Hermete commented Mar 10, 2021

Thanks! But...where can I put the query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment