php - How to exclude certain category in SQL Statement -
here's current codes popular post wordpress wp_post table. how can exclude in categories such 3 or 4?
$popularposts = "select id,post_title {$wpdb->prefix}posts post_status = 'publish' , post_type = 'post' order comment_count desc limit 0,".$pop_posts; $posts = $wpdb->get_results($popularposts); 
dugg through web , stackoverflow, solved problem. still need add
order comment_count desc limit 0,".$pop_posts somewhere in following code.
$popularposts  = "select * $wpdb->posts  inner join $wpdb->term_relationships on($wpdb->posts.id = $wpdb->term_relationships.object_id)   inner join $wpdb->term_taxonomy on($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)    ($wpdb->term_taxonomy.term_id <> 3      , $wpdb->term_taxonomy.term_id <> 4      , $wpdb->term_taxonomy.taxonomy = 'category'       , $wpdb->posts.post_type = 'post'      , $wpdb->posts.post_status = 'publish')"; 
Comments
Post a Comment