Skip to content

Instantly share code, notes, and snippets.

@phylaxis
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phylaxis/11459477 to your computer and use it in GitHub Desktop.
Save phylaxis/11459477 to your computer and use it in GitHub Desktop.
SDGC Tribe Events Function
function sdgc_get_events($start=null,$end=null) {
global $post;
$current_date = isset($start) ? date('j M Y', $start) : date('j M Y', strtotime('-1 day'));
$end_date = isset($end) ? date('j M Y', $end) : date('j M Y', strtotime('+6 day'));
$get_posts = tribe_get_events(array('start_date'=>$current_date,'end_date'=>$end_date, 'eventDisplay'=>'upcoming', 'posts_per_page'=>5 ) );
printf('<table class="sdgc-events">');
printf('<tbody>');
foreach($get_posts as $post) {
setup_postdata($post);
$dt = tribe_get_start_date($post->ID, true, 'j M Y');
$cd = new DateTime($dt);
$ft = $cd->format('n/j');
if((strtotime($dt) > strtotime($current_date)) && (strtotime($dt) < strtotime($end_date)))
{
printf('<tr><td class="sdgc-event-item"><a href="%s"><span class="primary-color-light">%s</span> - <span class="sdgc-event-title">%s</span></a></td><td class="sdgc-chevron"><a href="%s"><i class="fa fa-lg fa-chevron-circle-right"></i></a></td></tr>', get_permalink(), $ft, get_the_title(), get_permalink());
}
} //endforeach
printf('</tbody>');
printf('</table>');
wp_reset_query();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment