Created
October 8, 2019 12:24
-
-
Save mgibbs189/21f998a8cefd602c85e07c3f6e9f2418 to your computer and use it in GitHub Desktop.
FacetWP - force a maximum posts_per_page (PHP 7.3+)
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 | |
add_filter( 'facetwp_query_args', function( $args, $class ) { | |
$per_page = (int) $args['posts_per_page'] ?? get_option( 'posts_per_page', 10 ); | |
$args['posts_per_page'] = min( $per_page, 100 ); // maximum of 100 results | |
return $args; | |
}, 999, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment