function widget($args, $instance) { $cache = nxt_cache_get('widget_recent_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } 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') : $instance['title'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 10; } $r = new nxt_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul> <?php while ($r->have_posts()) { $r->the_post(); ?> <li><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?> "><?php if (get_the_title()) { the_title(); } else { the_ID(); } ?> </a></li> <?php } ?> </ul> <?php echo $after_widget; // Reset the global $the_post as this query will have stomped on it nxt_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); nxt_cache_set('widget_recent_posts', $cache, 'widget'); }
function widget($args, $instance) { $cache = nxt_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'; $nxtq_args = array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true); if ($show == 'popular') { $nxtq_args['orderby'] = 'comment_count'; } $r = new nxt_Query($nxtq_args); if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php while ($r->have_posts()) { $r->the_post(); ?> <div class="post"> <div class="post-img fl"><a href="<?php the_permalink(); ?> "><?php the_post_thumbnail('post-small'); ?> </a></div> <h4 class="post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <span> <?php _e('On', 'huddle'); ?> <?php the_time(get_option('date_format')); ?> , <?php _e('with', 'huddle'); ?> <?php comments_popup_link(__('0 Comments', 'huddle'), __('1 Comment', 'huddle'), __('% Comments', 'huddle')); ?> </span> <div class="clf"></div> </div><!--post--> <?php } ?> <?php echo $after_widget; ?> <?php // Reset the global $the_post as this query will have stomped on it nxt_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); nxt_cache_set('widget_recent_posts', $cache, 'widget'); }
/** * Destroy the previous query and set up a new query. * * This should be used after {@link query_posts()} and before another {@link * query_posts()}. This will remove obscure bugs that occur when the previous * nxt_query object is not destroyed properly before another is set up. * * @since 2.3.0 * @uses $nxt_query */ function nxt_reset_query() { unset($GLOBALS['nxt_query']); $GLOBALS['nxt_query'] = $GLOBALS['nxt_the_query']; nxt_reset_postdata(); }
<?php esc_html_e('by', 'Modest'); ?> <?php the_author_posts_link(); } if (in_array('date', get_option('modest_postinfo2'))) { ?> <?php esc_html_e('on', 'Modest'); ?> <?php the_time(get_option('modest_date_format')); } if (in_array('categories', get_option('modest_postinfo2'))) { ?> <?php esc_html_e('in', 'Modest'); ?> <?php the_category(', '); } if (in_array('comments', get_option('modest_postinfo2'))) { ?> | <?php comments_popup_link(esc_html__('0 comments', 'Modest'), esc_html__('1 comment', 'Modest'), '% ' . esc_html__('comments', 'Modest')); } ?> <?php nxt_reset_postdata(); }