name = __('Huddle: Posts', 'huddle'); $this->widget_options['description'] = __('The most recent/popular posts on your site', 'huddle'); } function widget($args, $instance) { $cache = wp_cache_get('widget_recent_posts', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Recent Posts', 'huddle' ) : $instance['title'], $instance, $this->id_base); if ( ! $number = absint( $instance['number'] ) ) $number = 10; $thumbs = isset($instance['thumbs']) && $instance['thumbs']; $show = isset($instance['show']) ? $instance['show'] : 'recent'; $wpq_args = array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true); if($show == 'popular') { $wpq_args['orderby'] = 'comment_count'; } $r = new WP_Query($wpq_args); if ($r->have_posts()) : ?> have_posts()) : $r->the_post(); ?>
/>