Note: You are viewing the documentation for Version 3View Version 4 Docs

Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

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

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP