| 2748 | | $sticky_posts = get_option('sticky_posts'); |
| 2749 | | if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) { |
| 2750 | | $num_posts = count($this->posts); |
| 2751 | | $sticky_offset = 0; |
| 2752 | | // Loop over posts and relocate stickies to the front. |
| 2753 | | for ( $i = 0; $i < $num_posts; $i++ ) { |
| 2754 | | if ( in_array($this->posts[$i]->ID, $sticky_posts) ) { |
| 2755 | | $sticky_post = $this->posts[$i]; |
| 2756 | | // Remove sticky from current position |
| 2757 | | array_splice($this->posts, $i, 1); |
| 2758 | | // Move to front, after other stickies |
| 2759 | | array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); |
| 2760 | | // Increment the sticky offset. The next sticky will be placed at this offset. |
| 2761 | | $sticky_offset++; |
| 2762 | | // Remove post from sticky posts array |
| 2763 | | $offset = array_search($sticky_post->ID, $sticky_posts); |
| 2764 | | unset( $sticky_posts[$offset] ); |
| | 2751 | if ( $this->is_home && $page <= 1 && ! $q['ignore_sticky_posts'] && $q['include_sticky'] ) { |
| | 2752 | $sticky_posts = get_option( 'sticky_posts' ); |
| | 2753 | if ( ! empty( $sticky_posts ) ) { |
| | 2754 | $num_posts = count($this->posts); |
| | 2755 | $sticky_offset = 0; |
| | 2756 | // Loop over posts and relocate stickies to the front. |
| | 2757 | for ( $i = 0; $i < $num_posts; $i++ ) { |
| | 2758 | if ( in_array($this->posts[$i]->ID, $sticky_posts) ) { |
| | 2759 | $sticky_post = $this->posts[$i]; |
| | 2760 | // Remove sticky from current position |
| | 2761 | array_splice($this->posts, $i, 1); |
| | 2762 | // Move to front, after other stickies |
| | 2763 | array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); |
| | 2764 | // Increment the sticky offset. The next sticky will be placed at this offset. |
| | 2765 | $sticky_offset++; |
| | 2766 | // Remove post from sticky posts array |
| | 2767 | $offset = array_search($sticky_post->ID, $sticky_posts); |
| | 2768 | unset( $sticky_posts[$offset] ); |
| | 2769 | } |