[Plugin: The Events Calendar] Want to show 5 upcoming events outside of the sidebar
-
Recently I had to design a theme that had required calander and to show 5 upcoming events/items outside of the sidebar.
The Events Calendar (TEC) didn’t seem to support this out the box and with use of wp_query I was able to solve the problem, now I’m sharing it with you so if can be of help to others:
<div> <?php $calender = get_cat_ID( 'Events' ); $calender_link = get_category_link( $calender );?> <h2>Coming Up</h2> <?php global $spEvents; $spEvents->loadDomainStylesScripts();?> <div id="tec-content main" class="upcoming"> <div id="tec-events-loop" class="tec-events post-list clearfix"> <?php $todaysDate = date('Y-m-d G:i:s'); $cal_query = new wp_query('category_name=Events&posts_per_page=5&meta_key=_EventStartDate&meta_compare=>=&meta_value='.$todaysDate.'&orderby=meta_value&order=ASC'); ?> <?php while ($cal_query->have_posts()) : $cal_query->the_post(); ?> <div id="post-<?php the_ID() ?>" class="tec-event post clearfix<?php echo $alt ?>"> <div style="clear:both;"></div> <?php the_title('<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>'); ?> <!-- End tec-event-entry --> </div> <!-- End post --> <?php $alt = ( empty( $alt ) ) ? ' alt' : '';?> <?php endwhile; // posts ?> </div> </div> </div> <span id="more"><a href="<?php echo $calender_link;?>">more »</a></span> </div>
Do with it what you will, if you want to show more/less posts alter the wp_query.
Hope the above snippet helps someone
https://www.ads-software.com/extend/plugins/the-events-calendar/
- The topic ‘[Plugin: The Events Calendar] Want to show 5 upcoming events outside of the sidebar’ is closed to new replies.