= 6124){ $from = " FROM (((("; $from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)"; $from .= " INNER JOIN $term_relationships_tb ON $post_tb.ID = $term_relationships_tb.object_id)"; $from .= " INNER JOIN $term_taxonomy ON $term_relationships_tb.term_taxonomy_id = $term_taxonomy.term_taxonomy_id)"; $from .= " INNER JOIN $terms_tb ON $term_taxonomy.term_id = $terms_tb.term_id)"; $from .= " INNER JOIN $user_tb ON $post_tb.post_author = $user_tb.ID"; $where = " WHERE ($post_tb.post_type = 'post') AND ($post_tb.post_status = 'publish')"; if ($cat_select) { $where .= " AND ($term_taxonomy.term_id IN ($cat_id))"; } if (!empty($tag_select)) { $tag_id_list= get_tag_id($tag_select); if (!empty($tag_id_list)) $where .= " AND ($term_taxonomy.term_id IN ($tag_id_list))"; } } else { $from = " FROM (("; $from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)"; $from .= " LEFT JOIN $post2cat_tb ON $post_tb.ID = $post2cat_tb.post_id)"; $from .= " INNER JOIN $user_tb ON $post_tb.post_author = $user_tb.ID"; $where = " WHERE ($post_tb.post_status = 'publish') AND (UNIX_TIMESTAMP($post_tb.post_date) <= UNIX_TIMESTAMP())" ; if ($cat_select) { $where .= " AND ($post2cat_tb.category_id IN ($cat_id))"; } } if ($show_month_range > 0) { $where .= " AND (UNIX_TIMESTAMP($post_tb.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -$show_month_range month)))"; } $order_limmit = " GROUP BY $post_tb.ID ORDER BY $view_tb.post_views DESC LIMIT 0, $disp_count"; $populars = $wpdb->get_results($select . $from . $where . $order_limmit); foreach ($populars as $popular){ $wp_query->in_the_loop = true; //for use the_tags() in multi lopp $r = new WP_Query("p=$popular->ID"); if($r->have_posts()){ $r->the_post(); ob_start(); the_ID(); $post_id = ob_get_contents(); ob_end_clean(); ob_start(); the_title(); $title = ob_get_contents(); ob_end_clean(); ob_start(); the_permalink(); $permalink = ob_get_contents(); ob_end_clean(); ob_start(); the_author_posts_link(); $author = ob_get_contents(); ob_end_clean(); ob_start(); the_category(' • '); $category = ob_get_contents(); ob_end_clean(); ob_start(); the_tags(__('Tags:', 'kubrick') . ' ',' • ',''); $tags = ob_get_contents(); ob_end_clean(); ob_start(); the_modified_date($date_format); $post_modified_date = ob_get_contents(); ob_end_clean(); ob_start(); the_modified_date($time_format); $post_modified_time = ob_get_contents(); ob_end_clean(); ob_start(); the_time($date_format); $post_date = ob_get_contents(); ob_end_clean(); ob_start(); the_time($time_format); $post_time = ob_get_contents(); ob_end_clean(); ob_start(); comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); $comments_popup_link = ob_get_contents(); ob_end_clean(); $post_title = '' . $title . ''; $post_date_time = $post_date . ' ' . $post_time ; $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ; $trackback_url = trackback_url(false); $post_viwes = xpress_post_views_count($post_id,'views: %d' ,false); // if (empty($tags)) $tags = __('Not Tag'); $row_data = array( 'post_id' => $post_id , 'post_title' => $post_title , 'post_date' => $post_date , 'post_time' => $post_time , 'post_date_time' => $post_date_time , 'post_modified_date' => $post_modified_date , 'post_modified_time' => $post_modified_time , 'post_modified_date_time' => $post_modified_date_time , 'post_author' => $author , 'post_category' => $category , 'post_tags' => $tags, 'post_views' => $post_viwes, 'comment_link' => $comments_popup_link , 'trackback_url' => $trackback_url ); $block['contents']['item'.$item_no] = $row_data; $item_no++; } } // end of foreach $block['data_count'] = $item_no; //xml unserialise error return $block ; } function get_tag_id($tag_list = ''){ global $wpdb,$wp_query; if (empty($tag_list)) return ''; $tag_arrys = explode(',',$tag_list); $tag_str = ''; foreach ($tag_arrys as $tag_s){ if (!empty($tag_str)) $tag_str .= ','; $tag_str .= "'" . $tag_s . "'"; } $db_prefix = get_wp_prefix(); $db_xpress_terms = $db_prefix . 'terms'; // upper 2.3 $db_xpress_term_taxonomy = $db_prefix . 'term_taxonomy'; // upper 2.3 $query = " SELECT $db_xpress_terms.term_id as tag_ID FROM $db_xpress_terms LEFT JOIN $db_xpress_term_taxonomy ON $db_xpress_terms.term_id = $db_xpress_term_taxonomy.term_id WHERE $db_xpress_term_taxonomy.taxonomy = 'post_tag' AND $db_xpress_terms.name IN ($tag_str) "; $tags = $wpdb->get_results($query); $no =0; foreach ($tags as $tag){ $tags_id[$no] = $tag->tag_ID; $no++; } $tags_id_list = implode(',' , $tags_id); return $tags_id_list; } ?>