Last active
August 29, 2015 14:00
-
-
Save phylaxis/11459477 to your computer and use it in GitHub Desktop.
SDGC Tribe Events Function
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
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