Choose search results displayed per page

I want to offer the option of allowing someone to choose the number of search results displayed on a page - similar to the function on this site: e.g. 15, 30, 50 per page. I am using the Relevanssi search plugin but didn’t find an option. Any help appreciated.

posts_per_page is the way to go.
Just add this to your functions.php file:

add_filter('post_limits', 'postsperpage');
function postsperpage($limits) {
	if (is_search()) {
		global $wp_query;
		$wp_query->query_vars['posts_per_page'] = 10;
	return $limits;

And adjust the value (10) to whatever you want.
This will work with Premium version 1.4.4 and upwards, as well as free 2.9.2. and upwards.



Just been playing around with this.
If you want to do it like the stackexchange site, that the user can select how many search results they wish to be displayed on a page, you could add a drop-down menu (or similar) to the WordPress search form.
The value that the user selects can then be picked up in the $_GET superglobal in functions.php
You could then write:

$wp_query->query_vars['posts_per_page'] = $_GET["delimit"];

where delimit is the name you gave your drop-down.

Hi Pullo, thanks for the help. I’ll try out your suggestion.