Skip to content

Instantly share code, notes, and snippets.

@alwayscoding
Created March 26, 2013 08:31
Show Gist options
  • Save alwayscoding/5243906 to your computer and use it in GitHub Desktop.
Save alwayscoding/5243906 to your computer and use it in GitHub Desktop.
WORDPRESS: LIMIT POSTS NUMBER IN ARCHIVE PAGE
/**
* set the limit number of posts in archive page
* @return none
*/
function limit_posts_per_archive_page() {
if ( is_date() )
$limit = 10;
elseif ( is_search() )
$limit = 10;
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