Created
March 21, 2016 13:11
-
-
Save davidperezgar/e56ef6d4dbab4c6b5d3d to your computer and use it in GitHub Desktop.
Limit Posts per archive Page WordPress
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
function limit_posts_per_archive_page() { | |
if ( is_category() ) | |
$limit = 2; | |
elseif ( is_search() ) | |
$limit = 1; | |
else | |
$limit = get_option('posts_per_page'); | |
set_query_var('posts_per_archive_page', $limit); | |
} | |
add_filter('pre_get_posts', 'limit_posts_per_archive_page'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment