Changeset 21928 for trunk/wp-includes/query.php
- Timestamp:
- 09/20/2012 02:55:54 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r21890 r21928 980 980 981 981 /** 982 * Amount of posts if limit clause was not used. 982 * The amount of found posts for the current query. 983 * 984 * If limit clause was not used, equals $post_count. 983 985 * 984 986 * @since 2.1.0 … … 2631 2633 2632 2634 if ( 'ids' == $q['fields'] ) { 2633 $this->posts = $wpdb->get_col($this->request); 2635 $this->posts = $wpdb->get_col( $this->request ); 2636 $this->post_count = count( $this->posts ); 2637 $this->set_found_posts( $q, $limits ); 2634 2638 2635 2639 return $this->posts; … … 2637 2641 2638 2642 if ( 'id=>parent' == $q['fields'] ) { 2639 $this->posts = $wpdb->get_results($this->request); 2643 $this->posts = $wpdb->get_results( $this->request ); 2644 $this->post_count = count( $this->posts ); 2645 $this->set_found_posts( $q, $limits ); 2640 2646 2641 2647 $r = array(); … … 2659 2665 2660 2666 if ( $ids ) { 2667 $this->posts = $ids; 2661 2668 $this->set_found_posts( $q, $limits ); 2662 2669 _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 2663 $this->posts = $ids;2664 2670 } else { 2665 2671 $this->posts = array(); 2666 $this->found_posts = $this->max_num_pages = 0;2667 2672 } 2668 2673 } else { … … 2767 2772 $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) ); 2768 2773 2769 $this->post_count = count( $this->posts);2774 $this->post_count = count( $this->posts ); 2770 2775 2771 2776 // Always sanitize … … 2784 2789 } 2785 2790 2791 /** 2792 * Set up the amount of found posts and the number of pages (if limit clause was used) 2793 * for the current query. 2794 * 2795 * @since 3.5.0 2796 * @access private 2797 */ 2786 2798 function set_found_posts( $q, $limits ) { 2787 2799 global $wpdb; 2788 2800 2789 if ( $q['no_found_rows'] || empty( $limits ))2801 if ( $q['no_found_rows'] || ! $this->posts ) 2790 2802 return; 2791 2803 2792 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2804 if ( ! empty( $limits ) ) 2805 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2806 else 2807 $this->found_posts = count( $this->posts ); 2808 2793 2809 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2794 2810 2795 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2811 if ( ! empty( $limits ) ) 2812 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2796 2813 } 2797 2814
Note: See TracChangeset
for help on using the changeset viewer.