diff --git wp-includes/query.php wp-includes/query.php
index bc6edea..cefe9ca 100644
|
|
class WP_Query { |
1951 | 1951 | $fields = ''; |
1952 | 1952 | $post_status_join = false; |
1953 | 1953 | $page = 1; |
| 1954 | $expand_ids = false; |
1954 | 1955 | |
1955 | 1956 | if ( isset( $q['caller_get_posts'] ) ) { |
1956 | 1957 | _deprecated_argument( 'WP_Query', '3.1', __( '"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.' ) ); |
… |
… |
class WP_Query { |
2597 | 2598 | $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; |
2598 | 2599 | } |
2599 | 2600 | |
| 2601 | if ( "$wpdb->posts.*" == $fields ) { |
| 2602 | $fields = "$wpdb->posts.ID"; |
| 2603 | $expand_ids = true; |
| 2604 | } |
| 2605 | |
2600 | 2606 | if ( ! empty($groupby) ) |
2601 | 2607 | $groupby = 'GROUP BY ' . $groupby; |
2602 | 2608 | if ( !empty( $orderby ) ) |
… |
… |
class WP_Query { |
2626 | 2632 | return $r; |
2627 | 2633 | } |
2628 | 2634 | |
2629 | | $this->posts = $wpdb->get_results($this->request); |
| 2635 | if ( $expand_ids ) { |
| 2636 | $ids = $wpdb->get_col( $this->request ); |
| 2637 | |
| 2638 | if ( $ids ) { |
| 2639 | if ( !$q['no_found_rows'] && !empty( $limits ) ) { |
| 2640 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
| 2641 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| 2642 | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |
| 2643 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2644 | } |
| 2645 | |
| 2646 | $query = sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s) $orderby", join( ",", $ids ) ); |
| 2647 | $this->posts = $wpdb->get_results($query); |
| 2648 | } else { |
| 2649 | $this->found_posts = $this->max_num_pages = 0; |
| 2650 | $this->posts = array(); |
| 2651 | } |
| 2652 | } else { |
| 2653 | $this->posts = $wpdb->get_results($this->request); |
| 2654 | } |
2630 | 2655 | |
2631 | 2656 | // Raw results filter. Prior to status checks. |
2632 | 2657 | if ( !$q['suppress_filters'] ) |
… |
… |
class WP_Query { |
2645 | 2670 | $this->comment_count = count($this->comments); |
2646 | 2671 | } |
2647 | 2672 | |
2648 | | if ( !$q['no_found_rows'] && !empty($limits) ) { |
| 2673 | if ( !$q['no_found_rows'] && !empty($limits) && !$expand_ids ) { |
2649 | 2674 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
2650 | 2675 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
2651 | 2676 | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |