/** * Display the widget content on the front-end * * @since 1.0.0 * @param array $args * @param array $instance */ public function widget($args, $instance) { extract($args); // widget options $number = !empty($instance['number']) ? absint($instance['number']) : 5; // widget query $p = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'post_type' => $this->_postType->get('identifier'), 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true))); // the loop if ($p->have_posts()) { echo $before_widget; // each post while ($p->have_posts()) { $p->the_post(); // display the post include plugin_dir_path(__FILE__) . 'Includes/Templates/WidgetPost.php'; } echo $after_widget; } }