Skip to content

Instantly share code, notes, and snippets.

@mestrewp
Created May 28, 2012 18:29
Show Gist options
  • Save mestrewp/2820524 to your computer and use it in GitHub Desktop.
Save mestrewp/2820524 to your computer and use it in GitHub Desktop.
CTP custom post per page
<?php
// Posts per page on CPT
function cs_custom_posts_per_page_CPT( $query ) {
switch ( $query->query_vars['post_type'] ) {
case 'album-de-fotos':
$query->query_vars['posts_per_page'] = 9;
break;
case 'loja':
$query->query_vars['posts_per_page'] = 15;
break;
default:
break;
}
return $query;
}
add_filter( 'pre_get_posts', 'cs_custom_posts_per_page_CPT' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment