| 1067 | | $count = 0; |
| 1068 | | foreach ( $q['tag_slug__and'] as $tag_and ) { |
| 1069 | | $join .= " LEFT JOIN $wpdb->term_relationships AS tr$count ON ($wpdb->posts.ID = tr$count.object_id) LEFT JOIN $wpdb->term_taxonomy AS tt$count ON (tr$count.term_taxonomy_id = tt$count.term_taxonomy_id) LEFT JOIN $wpdb->terms AS term$count ON (tt$count.term_id = term$count.term_id) "; |
| 1070 | | $whichcat .= " AND term$count.slug = '$tag_and' "; |
| 1071 | | $count++; |
| 1072 | | } |
| | 1067 | $tsql = "SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id) LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) LEFT JOIN $wpdb->terms t ON (tt.term_id = t.term_id)"; |
| | 1068 | $tsql .= "WHERE tt.taxonomy = 'post_tag' AND t.slug IN ('" . implode("', '", $q['tag_slug__and']) . "')"; |
| | 1069 | $tsql .= "GROUP BY p.ID HAVING count(p.ID) = " . count($q['tag_slug__and']); |
| | 1070 | $post_ids = $wpdb->get_col($tsql); |
| | 1071 | |
| | 1072 | if ( count($post_ids) ) |
| | 1073 | $where .= "AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; |
| | 1074 | else |
| | 1075 | $where = "AND 0 = 1"; |
| | 1076 | |