WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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