Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Erhalten Sie Beiträge aus allen Kategorien außer einer Kategorie

Versuchen Sie es unten:-

14 ist die Kategorie-ID

 $request = $wpdb->prepare("SELECT * FROM $wpdb->posts 
  LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)  
  LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)  

  WHERE ($wpdb->term_taxonomy.term_id <> 14  
     AND $wpdb->term_taxonomy.taxonomy = 'category'   
     AND $wpdb->posts.post_type = 'post'  
     AND $wpdb->posts.post_status = 'publish'
     AND post_title like '%$search%'
     AND post_date >= '" . date('Y-m-d').")");