Skip to content

Instantly share code, notes, and snippets.

@fueledbyboredom
Created February 14, 2017 16:06
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 fueledbyboredom/bdc5651d7ec796637ed742cc12c1f564 to your computer and use it in GitHub Desktop.
Save fueledbyboredom/bdc5651d7ec796637ed742cc12c1f564 to your computer and use it in GitHub Desktop.
Get more search results per page, in this example it is set to return 25 per page.
<?php
function mwpf_search_results_per_page( $query ) {
global $wp_the_query;
if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_search() ) ) {
$query->set( 'mwpf_search_results_per_page', 25 );
}
return $query;
}
add_action( 'pre_get_posts', 'mwpf_search_results_per_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment