/ Published in: PHP
This shortcode was tested with The Events Calendar version 3.3.1
Usage: [upcoming_events limit="6"]
Usage: [upcoming_events limit="6"]
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function upcoming_events_shortcode($atts){ 'limit' => 5, ), $atts ) ); $i=0; $result='<div id="event-box"><ul>'; foreach ( $upcoming_events as $post ) { $stime = tribe_get_start_date( $post->ID, false, 'g:i a' ); $etime = tribe_get_end_date( $post->ID, false, 'g:i a' ); $result .= '<li><h4><a class="blacklink" href="' . get_permalink($post->ID) . '">'; if( $stime == '12:00 am' ){ $result .= $sdate; //all day event }else if( $stime != $etime ){ $result .= $sdate . ' <span class="time">@ ' . $stime . ' - ' . $etime . '</span>'; }else{ $result .= $sdate . ' <span class="time">@ ' . $stime . '</span>'; } $result .= '</a></h4><p>'; $title = $post->post_title; $result .= '</p>'; if( ($i%$limit) == 0 && $i>0) { $result .= '</li>'; } $i++; }//end foreach $result .= '</ul></div><!-- end #event-box -->'; return $result; } add_shortcode( 'upcoming_events', 'upcoming_events_shortcode' );
URL: http://wordpress.org/plugins/the-events-calendar/