diff --git wp-includes/query.php wp-includes/query.php
index d70348c..e34b942 100644
|
|
class WP_Query { |
2600 | 2600 | if ( !$q['no_found_rows'] && !empty($limits) ) |
2601 | 2601 | $found_rows = 'SQL_CALC_FOUND_ROWS'; |
2602 | 2602 | |
2603 | | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
2604 | | if ( !$q['suppress_filters'] ) |
| 2603 | $ids_request = "SELECT $found_rows $distinct {$wpdb->posts}.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 2604 | $ids_res = $wpdb->get_results($ids_request); |
| 2605 | |
| 2606 | if ( !$q['no_found_rows'] && !empty($limits) ) { |
| 2607 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
| 2608 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| 2609 | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |
| 2610 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2611 | } |
| 2612 | |
| 2613 | $ids_list = array(); |
| 2614 | foreach ( $ids_res as $id_row ) { |
| 2615 | $ids_list[] = $id_row->ID; |
| 2616 | } |
| 2617 | $ids_where = " AND 0"; |
| 2618 | if ( count($ids_list) > 0 ) { |
| 2619 | $ids_where = " AND {$wpdb->posts}.ID IN (" . implode(',', $ids_list) . ")"; |
| 2620 | } |
| 2621 | |
| 2622 | $this->request = " SELECT $distinct $fields FROM $wpdb->posts WHERE 1=1 $ids_where $orderby"; |
| 2623 | if ( !$q['suppress_filters'] ) |
2605 | 2624 | $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); |
2606 | 2625 | |
2607 | 2626 | if ( 'ids' == $q['fields'] ) { |
… |
… |
class WP_Query { |
2639 | 2658 | $this->comment_count = count($this->comments); |
2640 | 2659 | } |
2641 | 2660 | |
2642 | | if ( !$q['no_found_rows'] && !empty($limits) ) { |
2643 | | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
2644 | | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
2645 | | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |
2646 | | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
2647 | | } |
2648 | | |
2649 | 2661 | // Check post status to determine if post should be displayed. |
2650 | 2662 | if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { |
2651 | 2663 | $status = get_post_status($this->posts[0]); |