Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created December 11, 2018 22:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/2763f1d6ca94d609baa007c7b722a35c to your computer and use it in GitHub Desktop.
Save billerickson/2763f1d6ca94d609baa007c7b722a35c to your computer and use it in GitHub Desktop.
<?php
/**
* DPS, include sticky posts in posts_per_page calculation
* @see https://wordpress.org/support/topic/number-of-posts-with-sticky/
*/
function be_dps_include_sticky_count( $output, $atts ) {
global $be_post_counter;
if( empty( $be_post_counter ) )
$be_post_counter = 1;
else
$be_post_counter++;
$posts_per_page = !empty( $atts['posts_per_page'] ) ? intval( $atts['posts_per_page'] ) : get_option( 'posts_per_page' );
if( $be_post_counter > $posts_per_page )
$output = '';
return $output;
}
add_filter( 'display_posts_shortcode_output', 'be_dps_include_sticky_count', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment