Created
March 26, 2013 08:31
-
-
Save alwayscoding/5243906 to your computer and use it in GitHub Desktop.
WORDPRESS: LIMIT POSTS NUMBER IN ARCHIVE PAGE
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
/** | |
* 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