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 currently have a page called "Blog" (slug "blog"), which loads a index.php. All posts in index.php belong to only one post category. A sidebar on index.php contains category links (via wp_list_categories) which load archive.php for that given taxonomy.

The problem I am running into is that I currently have the category base name set to the same slug as the page: "blog". I am aware that this can cause issues with the rewrite rules, but for the most part everything looks fine. The only issue is with pagination pages for index.php (mysite.com/blog/page/2 does not work while mysite.com/blog/foo-category/page/2 works fine).

Is there a rewrite rule that can help with my current situation? And if so some help would be appreciated.

If this is a bad idea, please speak up as well. I was hoping to achieve a somewhat RESTful url structure, but wordpresses permalink structure doesn't appear to be the most flexible.

Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is untested, but should work for you. Visit the permalinks settings page to flush rewrite rules after adding:

function wpa_fix_blog_pagination(){
    add_rewrite_rule(
        'blog/page/([0-9]+)/?$',
        'index.php?pagename=blog&paged=$matches[1]',
        'top'
    );
}
add_action( 'init', 'wpa_fix_blog_pagination' );
share|improve this answer
    
Thanks Milo, that worked perfectly. Since you seem to know a thing or two about rewrite rules, do you see anything wrong/dangerous about using this permalink structure down the road? –  Paul T Sep 18 '13 at 15:15

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.