Updated by Willy Bahuaud 2017-04-13 View revision File sticky.php Modified Side-by-side diff More Ignore whitespace Hide word diff add_filter( 'the_posts', 'sticky_count_offset', 10, 2 ); function sticky_count_offset( $posts, $q ) { - if ( $q->get( 'ppp_include_sticky' ) && 0 < $q->get( 'posts_per_page' ) ) { + if ( $q->get( 'ppp_include_sticky' ) + && 0 < $q->get( 'posts_per_page' ) + && false == $q->get( 'ignore_sticky_posts' ) ) { $posts = array_slice( $posts, 0, $q->get( 'posts_per_page' ) ); } return $posts;
Created by Willy Bahuaud 2017-04-13 View revision File sticky.php Added Side-by-side diff More Ignore whitespace Hide word diff +<?php + +add_filter( 'query_vars', 'sticky_offset_query_var' ); +function sticky_offset_query_var( $vars ) { + $vars[] = 'ppp_include_sticky'; + return $vars; +} + +add_filter( 'the_posts', 'sticky_count_offset', 10, 2 ); +function sticky_count_offset( $posts, $q ) { + if ( $q->get( 'ppp_include_sticky' ) && 0 < $q->get( 'posts_per_page' ) ) { + $posts = array_slice( $posts, 0, $q->get( 'posts_per_page' ) ); + } + return $posts; +}