function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); global $xt; if ($xt->is_daogou) { $cats = get_the_terms(null, 'daogou_category'); if (!$cats || is_wp_error($cats)) { $cats = array(); } $cats = array_values($cats); foreach (array_keys($cats) as $key) { _make_cat_compat($cats[$key]); } $cids = array(); if (!empty($cats)) { foreach ($cats as $cat) { $cids[] = $cat->cat_ID; } } $cids = implode(',', $cids); $show = intval($instance['show']); $count = intval($instance['count']); $sortOrder = $instance['sortOrder']; $isDaogouList = $layout == 'span9' && $show == 2; if ($isDaogouList) { echo str_replace('xt-widget-blog', 'xt-widget-daogou', $before_widget); } else { echo $before_widget; } echo '<div class="hd"><h4 class="xt-bd-l" style="' . (empty($title) ? 'display:none' : '') . '"><span>' . $title . '</span></h4></div><div class="bd">'; $_params = array('post_type' => 'daogou', 'posts_per_page' => $count, 'orderby' => $sortOrder); if (!empty($cids)) { $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cids)); } query_posts($_params); if ($isDaogouList) { _xt_widget_blog_daogou($layout); } else { if ($show == 0) { echo '<ul class="xt-bd-list unstyled clearfix">'; } else { echo '<ul class="media-list clearfix">'; } $_post_count = 0; while (have_posts()) { the_post(); _xt_widget_blog_li($show, $_post_count); $_post_count++; } echo '</ul>'; } echo '</div>'; echo $after_widget; } }
function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $dataType = $instance['dataType']; $cid = $instance['cid']; $ids = apply_filters('xt_filter_ids', $instance['ids']); $page_size = intval($instance['count']); if ($dataType == 'cid') { if (intval($cid) == 0 || $cid == -1) { query_posts(array('post_type' => 'daogou', 'posts_per_page' => $page_size)); } else { $_params = array('post_type' => 'daogou', 'posts_per_page' => $page_size); if (!empty($cid) && $cid > 0) { $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cid)); } query_posts($_params); } } elseif ($dataType == 'ids') { query_posts(array('post__in' => explode(',', $ids), 'post_type' => 'daogou')); } echo $before_widget; echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($title) ? '' : ' style="display:none;"') . '><span>' . $title . '</span></h4></div><div class="bd">'; _xt_widget_blog_daogou($layout); echo '</div>'; echo $after_widget; }
function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $count = $instance['count']; global $wp; $params = $wp->query_vars['xt_param']; $page_no = $params['page']; $page_size = $count; $cid = $params['cid']; $s = $params['s']; $_params = array('post_type' => 'daogou', 'paged' => $page_no, 'posts_per_page' => $page_size, 's' => $s); if (!empty($cid)) { $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cid)); } query_posts($_params); echo $before_widget; echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($title) ? '' : ' style="display:none;"') . '><span>' . $title . '</span></h4></div><div class="bd">'; _xt_widget_blog_daogou($layout); echo '</div>'; echo $after_widget; echo '<div id="X_Pagination-Bottom" class="clearfix">'; echo '<div class="pagination xt-pagination-links" style="padding:0;margin:0 auto;">'; global $wp_query; $big = 100; // need an unlikely integer echo paginate_links(array('base' => xt_get_daogou_search_url(array_merge($params, array('page' => '%#%'))), 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'type' => 'list')); echo '</div></div>'; }