
Untitled
By: a guest on
Mar 25th, 2011 | syntax:
None | size: 1.09 KB | hits: 158 | expires: Never
$currentcatobj = get_category(get_query_var('cat'),false);
$currentcat = $currentcatobj->term_id;
$includecats = " AND $wpdb->posts.ID IN (
SELECT object_id
FROM $wpdb->term_relationships AS r
JOIN $wpdb->term_taxonomy AS x ON x.term_taxonomy_id = r.term_taxonomy_id
JOIN $wpdb->terms AS t ON t.term_id = x.term_id
WHERE x.taxonomy = 'category'
AND object_id IN
(
SELECT object_id
FROM $wpdb->term_relationships AS r
JOIN $wpdb->term_taxonomy AS x ON x.term_taxonomy_id = r.term_taxonomy_id
JOIN $wpdb->terms AS t ON t.term_id = x.term_id
WHERE x.taxonomy = 'category'
AND t.term_id IN (".$currentcat.")))";
$mostpopular = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_title $fields FROM $wpdb->posts $join WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_password = '' AND $range $force_pv $nopages $exclude $includecats GROUP BY $wpdb->posts.ID ORDER BY $sortby DESC LIMIT " . $instance['limit'] . "");
$cat_name = get_cat_name($currentcat);
$content = "$cat_name";