function wptouch_exclude_category($query) { $excluded = wptouch_excluded_cats(); if ($excluded) { $cats = explode(',', $excluded); $new_cats = array(); foreach ($cats as $cat) { $new_cats[] = trim($cat); } $query->set('category__not_in', $new_cats); } return $query; }
function exclude_category($query) { $cats = wptouch_excluded_cats(); $icats = explode(",", $cats); $new_cats = array(); foreach ($icats as $icat) { $new_cats[] = "-" . $icat; } $cats = implode(",", $new_cats); if ($query->is_home) { $query->set('cat', $cats); } return $query; }
function bnc_get_ordered_cat_list($num) { global $wpdb; if (wptouch_excluded_cats()) { $excluded_cats = wptouch_excluded_cats(); } else { $excluded_cats = 0; } echo '<ul>'; $sql = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}term_taxonomy INNER JOIN {$wpdb->prefix}terms ON {$wpdb->prefix}term_taxonomy.term_id = {$wpdb->prefix}terms.term_id WHERE taxonomy = 'category' AND {$wpdb->prefix}term_taxonomy.term_id NOT IN ({$excluded_cats}) AND count >= 1 ORDER BY count DESC LIMIT 0, {$num}"); if ($sql) { foreach ($sql as $result) { if ($result) { echo "<li><a href=\"" . get_category_link($result->term_id) . "\">" . $result->name . " <span>(" . $result->count . ")</span></a></li>"; } } } echo '</ul>'; }