Skip to content

Instantly share code, notes, and snippets.

@wpspeak
Created November 26, 2013 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpspeak/7653302 to your computer and use it in GitHub Desktop.
Save wpspeak/7653302 to your computer and use it in GitHub Desktop.
Overwrite number of posts in CPT archive page
<?php
//* Overwrite number of posts in CPT archive page
if ( !is_admin() ) {
add_filter( 'pre_get_posts', 'afn_cpt_posts_per_page' );
}
function afn_cpt_posts_per_page( $query ) {
if ( $query->query_vars['post_type'] == 'portfolio' ) $query->query_vars['posts_per_page'] = 6;
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment