Last active
May 4, 2020 18:24
-
-
Save vfontjr/333bd5b46d48417171c3bd42133eb89c to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/limit-number-of-posts-in-query/
This file contains 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 | |
function vmf_limit_main_search_posts( $limit, $query ) { | |
if ( ! is_admin() && $query->is_main_query() ) { | |
return 'LIMIT 0, 40'; | |
} | |
return $limit; | |
} | |
add_filter( 'post_limits', 'vmf_limit_main_posts', 10, 2 ); |
This file contains 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 | |
function vmf_limit_main_search_posts( $limit, $query ) { | |
if ( ! is_admin() && $query->is_search() ) { | |
return 'LIMIT 0, 40'; | |
} | |
return $limit; | |
} | |
add_filter( 'post_limits', 'vmf_limit_search_posts', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment