Last active
December 29, 2015 09:19
-
-
Save josephhinson/7649212 to your computer and use it in GitHub Desktop.
Insert this function into your functions file or plugin in order to filter your post type archive results.
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
<?php | |
function my_new_posts_filter($query) { | |
// in place of "press" put your custom post type -- you can add additional post types by duplicating the if block. | |
// you can also add more query variables such as 'order'. This is extremely useful | |
// the is_main_query makes sure you don't indiscriminantly filter secondary loops as well. | |
if ( !is_admin() && is_post_type_archive('book') && $query->is_main_query() ) { | |
$query->set( 'posts_per_page', '20' ); | |
} | |
} | |
add_action('pre_get_posts','my_new_posts_filter'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment