Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.