Skip to content

Instantly share code, notes, and snippets.

@arelthia
Created August 6, 2015 17:06
Show Gist options
  • Select an option

  • Save arelthia/5615fc819a63a4087d38 to your computer and use it in GitHub Desktop.

Select an option

Save arelthia/5615fc819a63a4087d38 to your computer and use it in GitHub Desktop.
Change the number of post that are displayed per page for specific CPTs
add_action( 'pre_get_posts', 'tht_change_cpt_posts_per_page' );
/**
* Change Posts Per Page for CPT Archive
*/
function tht_change_cpt_posts_per_page( $query ) {
if( $query->is_main_query() && !is_admin() && (is_post_type_archive( 'definitions' )|| is_post_type_archive( 'question' )) ) {
$query->set( 'posts_per_page', '18' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment