Skip to content

Instantly share code, notes, and snippets.

@briankompanee
Last active July 15, 2016 18:38
Show Gist options
  • Save briankompanee/92afaa78f33b0eaaa5d6e670ff0611ac to your computer and use it in GitHub Desktop.
Save briankompanee/92afaa78f33b0eaaa5d6e670ff0611ac to your computer and use it in GitHub Desktop.
WordPress: Change default search query to return custom number of posts per page.
<?php
/**
* Change the search page to return 25 posts per page in results.
* Add to functions.php
*/
add_filter('post_limits', 'search_postsperpage');
function search_postsperpage($limits) {
if (is_search()) {
global $wp_query;
//Change 25 to whatever number you desire.
$wp_query->query_vars['posts_per_page'] = 25;
}
return $limits;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment