Advertisement
miriamdepaula

WordPress:Fix 404 error Custom Post Type category pagination

Feb 3rd, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. /**
  3.  * This plugin will fix a 404 error when viewing a paginated category listing of
  4.  * a custom post type when the custom permalink string is /%category%/%postname%/
  5.  * The problem is the request only checks for items with the 'post' type
  6.  * To fix the problem, add custom post types to the request
  7.  */
  8. function fix_category_pagination($qs){
  9.     if(isset($qs['category_name']) && isset($qs['paged'])){
  10.         $qs['post_type'] = get_post_types($args = array(
  11.             'public'   => true,
  12.             '_builtin' => false
  13.         ));
  14.         array_push($qs['post_type'],'post');
  15.     }
  16.     return $qs;
  17. }
  18. add_filter('request', 'fix_category_pagination');
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement