-
-
Save billerickson/2763f1d6ca94d609baa007c7b722a35c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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