Last active
December 17, 2015 05:19
-
-
Save JiveDig/5557225 to your computer and use it in GitHub Desktop.
Set the number of posts per page (post count). Must be in functions.php
This file contains hidden or 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 number of posts per page | |
add_filter( 'pre_get_posts', 'be_archive_query' ); | |
// @link http://www.billerickson.net/customize-the-wordpress-query/ | |
function be_archive_query( $query ) { | |
if( $query->is_main_query() && $query->is_archive() ) { | |
$query->set( 'posts_per_page', 12 ); | |
} | |
} | |
// OR | |
If you don't want the change to affect backend | |
// Set the number of posts per page | |
add_filter( 'pre_get_posts', 'mwm_resource_affiliate_archive_query' ); | |
// @link http://www.billerickson.net/customize-the-wordpress-query/ | |
function mwm_resource_affiliate_archive_query( $query ) { | |
if ( ! is_admin() AND ( is_post_type_archive('resource') OR is_post_type_archive('affiliate') ) ) { | |
$query->set( 'posts_per_page', 15 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment