Last active
July 15, 2016 18:38
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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