public function widget($args, $instance) { $this->get_instance($instance); // before and after widget arguments are defined by themes echo $args['before_widget']; echo $args['before_title'] . __('Upcoming Events', 'scoutwp_plugin') . $args['after_title']; query_posts(array('post_type' => 'event', 'posts_per_page' => get_option('posts_per_page'), 'ignore_sticky_posts' => 1, 'posts_per_page' => $this->limit, 'meta_key' => 'event_start', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_value' => time() - 3600, 'meta_compare' => '>')); if (have_posts()) { echo "<div class=\"fp-widget container\">"; while (have_posts()) { the_post(); // get the featured image $image = $this->image != 'none' ? get_the_post_thumbnail(get_the_ID(), $this->image) : ''; $event = new Event(get_post()); ?> <article class="event"> <?php the_title('<h4><a href="' . get_the_permalink() . '">', '</a></h4>'); echo $image; ?> <?php if ($this->date) { ?> <p class="icon-clock"><time datetime="<?php echo date('c', $event->start); ?> "><strong><?php echo date(get_option('date_format'), $event->start); ?> </strong> <?php echo date(get_option('time_format'), $event->start); ?> </time></p> <?php } ?> <?php if ($this->location && $event->address) { ?> <p class="icon-location"><?php echo esc_html($event->location()); ?> </p> <?php } ?> <?php if ($this->price && $event->price) { ?> <p class="icon-ticket"><?php echo esc_html($event->price); ?> </p> <?php } ?> </article> <?php } echo '</div>'; echo '<a href="' . Events::get_link() . '" class="button-link icon-right-big">' . __('View more events', 'scoutwp_plugin') . '</a>'; } else { echo "<p>No upcoming events to show</p>"; } wp_reset_query(); echo $args['after_widget']; }