php - Wordpress: How to get posts that don't contain a specific category with a custom query -
i need display posts don't contain specific category. use following query, retrive post contains category 81 since post contains other categories. there way sort out?
select p1.*, wm2.meta_value wp_posts p1 left join wp_postmeta wm1 on ( wm1.post_id = p1.id , wm1.meta_value not null , wm1.meta_key = '_thumbnail_id' ) left join wp_postmeta wm2 on ( wm1.meta_value = wm2.post_id , wm2.meta_key = '_wp_attached_file' , wm2.meta_value not null ) left join wp_term_relationships wtr on ( object_id=p1.id ) p1.post_status='publish' , p1.post_type='post' , `term_taxonomy_id`<>81 group id order p1.post_date desc limit 0,10
thank you!
this should works
select p1.*, wm2.meta_value wp_posts p1 left join wp_postmeta wm1 on ( wm1.post_id = p1.id , wm1.meta_value not null , wm1.meta_key = '_thumbnail_id' ) left join wp_postmeta wm2 on ( wm1.meta_value = wm2.post_id , wm2.meta_key = '_wp_attached_file' , wm2.meta_value not null ) left join wp_term_relationships wtr on ( object_id=p1.id ) p1.post_status='publish' , p1.post_type='post' , object_id not in (select `object_id` wp_term_relationships `term_taxonomy_id`=81) group id order p1.post_date desc limit 0,10
Comments
Post a Comment