Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyskoczilova/342da21daae64d92b2e8caa70f583810 to your computer and use it in GitHub Desktop.
Save vyskoczilova/342da21daae64d92b2e8caa70f583810 to your computer and use it in GitHub Desktop.
<?php
function change_wp_search_size($query) {
if ( $query->is_search ) // Make sure it is a search page
$query->query_vars['posts_per_page'] = 10; // Change 10 to the number of posts you would like to show
return $query; // Return our modified query variables
}
add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom function onto the request filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment