Excluding categories from popular posts
-
I have a function that displays the top 5 popular posts, but I need to remove categories from it so they don’t appear in the popular posts section. The code is…
function wp_popular_posts($pop_posts = 5 , $thumb = true){ global $wpdb , $post; $orig_post = $post; $popularposts = "SELECT ID,post_title,post_date,post_author,post_content,post_type FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY comment_count DESC LIMIT 0,".$pop_posts; $posts = $wpdb->get_results($popularposts); if($posts){ global $post; foreach($posts as $post){ setup_postdata($post);?>Then it goes on to print out the post. I wanted to know if there’s an easy way to exclude certain categories within this??
I know about query_posts(cat=-4) but not sure if I could use that method here? if so where should I put it?
Any help is appreciated, thanks in advance!
The topic ‘Excluding categories from popular posts’ is closed to new replies.