1

I have a custom type and the slug is:

'rewrite' => array('slug' => 'blog/%blogs_tax%'),

And after register_post_type() I have a function to rewrite the slug variable.

I works fine, but I have problems with pagination...

When I try to access something like http://www.site.com/blog/job/page/2/ (job is the category), I receive 404.

The pagination with simple slug from an another custom type Like : 'slug' => 'cases/') works fine... the problem happens only when I use a variable in the slug (%blogs_tax% or another). How to fix it? Thanks.

  • you can not pass variables like that. – amit Aug 3 '12 at 17:07
  • make sure you're not passing 'pages' => false for rewrite as it will tell not to use rewrite rules for pagination. – amit Aug 3 '12 at 17:18
  • Amit, it is TRUE value. $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => 'blog/%blogs_tax%', 'pages' => true), 'taxonomies' => array('category', 'post_tag', 'blogs_tax'), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => true, 'menu_position' => null, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt') ); – gregolin Aug 6 '12 at 18:06
1

I got fix this problem with:

add_rewrite_rule('blog/([^/]*)/page/([0-9]+)?/?$', 'index.php?post_type=blog&blogs_tax=$matches[1]&paged=$matches[2]', 'top');

In functions.php, after register_post_type.

Very important: You must flush rules. It is easy to do changing the permalink.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.