Skip to content

Instantly share code, notes, and snippets.

@davidperezgar
Created March 21, 2016 13:11
Show Gist options
  • Save davidperezgar/e56ef6d4dbab4c6b5d3d to your computer and use it in GitHub Desktop.
Save davidperezgar/e56ef6d4dbab4c6b5d3d to your computer and use it in GitHub Desktop.
Limit Posts per archive Page WordPress
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