Last active
February 17, 2016 20:17
-
-
Save joshfeck/e2f6d67f981df6dc01f5 to your computer and use it in GitHub Desktop.
A Genesis-ready page template for Event Espresso 4 that displays an archive of past events in an html table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Custom Event Archive Only Template | |
*/ | |
remove_action ( 'genesis_loop', 'genesis_do_loop' ); // Remove the standard loop | |
add_action( 'genesis_loop', 'custom_event_archive_only_loop' ); | |
function custom_posts_where_sql_for_only_expired() { | |
return ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end < "' . current_time( 'mysql', TRUE ) . '" '; | |
} | |
function custom_event_archive_only_loop() { | |
echo '<table>'; | |
$args = array( | |
'limit' => 100, | |
'show_expired' => TRUE, | |
'sort' => 'DESC', | |
'order_by' => 'start_date', | |
); | |
add_filter( 'posts_where', 'custom_posts_where_sql_for_only_expired' ); | |
$loop = new EE_Event_List_Query( $args ); | |
if( $loop->have_posts() ) { | |
// loop through posts | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
?> | |
<tr> | |
<td class="event_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td> | |
<td class="start_date"><?php espresso_event_date(); ?></td> | |
</tr> | |
<?php | |
endwhile; | |
} | |
remove_filter( 'posts_where', 'custom_posts_where_sql_for_only_expired' ); | |
wp_reset_postdata(); | |
echo '</table>'; | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment