public function widget($args, $instance) { extract($args); $anamEvent = new ANAMEvent(); $title = apply_filters('widget_title', $instance['title']); $post_count = 0; $post_limit = $instance['limit']; $query = $anamEvent->getCurrentEvents(); if ($query->have_posts()) { // before and after widget arguments are defined by themes echo $before_widget; if (!empty($title)) { if ($query->found_posts > $post_limit) { echo $args['before_title'] . $title . $args['after_title'] . '<a href="/events/current-events">more...<a>'; } else { echo $args['before_title'] . $title . $args['after_title']; } } while ($query->have_posts()) { $post_count++; $query->the_post(); if ($post_count <= $post_limit) { get_template_part('event-summary'); } } echo $after_widget; } wp_reset_query(); }
<?php /** * Template Name: Current Events * * Used to display a list of upcoming Event post types. * * When clicking on a single Event link, it will render 'single-event.php'. * * @package ANAM * * SEE: https://gist.github.com/aderaaij/6827478 */ $anamEvent = new ANAMEvent(); $query = $anamEvent->getCurrentEvents(); //http://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/ include locate_template('content-event-list.php');
<?php /** * Template Name: Recent Events * * Used to display a list of past Event post types. * * When clicking on a single Event link, it will render 'single-event.php'. * * @package ANAM * * SEE: https://gist.github.com/aderaaij/6827478 */ $anamEvent = new ANAMEvent(); $query = $anamEvent->getRecentEvents(); //http://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/ include locate_template('content-event-list.php');