FacetWP – force a maximum posts_per_page (PHP 7.3+)

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?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 );

{{/gist}}