Ticket #23336: 23336.3.diff
File 23336.3.diff, 1.9 KB (added by , 12 years ago) |
---|
-
wp-includes/query.php
2742 2742 2743 2743 // Put sticky posts at the top of the posts array 2744 2744 $sticky_posts = get_option('sticky_posts'); 2745 if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) { 2746 $num_posts = count($this->posts); 2745 2746 // Base sticky posts limit on Posts per Page setting 2747 $posts_per_page = (int) get_option( 'posts_per_page' ); 2748 if ( empty( $posts_per_page ) || $posts_per_page < 1 ) 2749 $posts_per_page = 20; 2750 2751 if ( $this->is_home && $page <= 1 && is_array( $sticky_posts ) && ! empty( $sticky_posts ) && ! $q['ignore_sticky_posts'] ) { 2752 2753 $sticky_posts = array_slice( $sticky_posts, 0, apply_filters( 'sticky_posts_home_query_limit', 10 * $posts_per_page ) ); // sanity limit 2754 $num_posts = count( $this->posts ); 2747 2755 $sticky_offset = 0; 2756 2748 2757 // Loop over posts and relocate stickies to the front. 2749 2758 for ( $i = 0; $i < $num_posts; $i++ ) { 2750 if ( in_array( $this->posts[$i]->ID, $sticky_posts) ) {2759 if ( in_array( $this->posts[$i]->ID, $sticky_posts ) ) { 2751 2760 $sticky_post = $this->posts[$i]; 2752 2761 // Remove sticky from current position 2753 array_splice( $this->posts, $i, 1);2762 array_splice( $this->posts, $i, 1 ); 2754 2763 // Move to front, after other stickies 2755 array_splice( $this->posts, $sticky_offset, 0, array($sticky_post));2764 array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); 2756 2765 // Increment the sticky offset. The next sticky will be placed at this offset. 2757 2766 $sticky_offset++; 2758 2767 // Remove post from sticky posts array 2759 $offset = array_search( $sticky_post->ID, $sticky_posts);2768 $offset = array_search( $sticky_post->ID, $sticky_posts ); 2760 2769 unset( $sticky_posts[$offset] ); 2761 2770 } 2762 2771 }