Created
January 3, 2012 09:45
-
-
Save chibani/1554288 to your computer and use it in GitHub Desktop.
WordPress : Hack to give a custom posts_per_page value for a custom post type
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
//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