SearchWP

This Documentation is for SearchWP Version 3

Available since: 1.0

searchwp_posts_per_page

View Parameters »

Many times you want a different number of posts per search results page. Further, you may want to customize that number per search engine. This filter allows you to customize how many results are returned for all search results pages.

Example: If you want to force 20 results per page for all supplemental search engines, add the following to your active theme’s functions.php:

<?php
function my_searchwp_posts_per_page( $posts_per_page, $engine, $terms, $page )
{
if( $engine != 'default' ) {
// if this is a supplemental search engine, show 20 results per page
return 20;
} else {
// it's the default search engine, return whatever it was originally
return $posts_per_page;
}
}
add_filter( 'searchwp_posts_per_page', 'my_searchwp_posts_per_page', 30, 4 );
view raw gistfile1.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$posts_per_page Integer

The default number of posts per page

$engine String

The search engine in use

$terms Array

The search query

$page Integer

The page of search results being displayed