Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
WordPress : Hack to give a custom posts_per_page value for a custom post type
//This code should be added in the plugin that manages the custom post type or in the functions.php of you theme
add_filter('request', 'hack_pagination');//Register the filter
/**
* Hack to give a custom posts_per_page value for a custom post type
* @param string $query_string automatically given by the filter
*/
function hack_pagination($query_string){
if($query_string['post_type']=='MY_CUSTOM_POST_TYPE' && !is_single() && !is_admin()) {
$query_string['posts_per_page'] = 2;//Number of posts I want in archive
}
return $query_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.