1

I always struggle with pagination in wordpress. I really wish that was a definitive guide to wordpress rewrite rules.

I have a site setup this way:

  1. permalink custom structure: /%category%/%postname%/
  2. I have a page named "blog"
  3. I have the reading settings making the page "blog" the Posts Page.
  4. I'm only using the index.php to list all posts
  5. No custom queries, just the regular loop

Everything works beautifully as long as I am viewing all posts. No issue with pagination here.

All posts -> domain.com/blog/ (works)
All posts page 2 -> domain.com/blog/page/2/ (works)

However as soon as click in a category, let's say "news", and try to see the next page I get a 404.

News -> domain.com/news (works)
News page 2 -> domain.com/news/page/2 (doesn't work)

Nothing atypical in the .htaccess file, and no other custom rewrite rules are present.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

So what I am doing wrong? This is pretty standard wordpress setup. I would also appreciate if someone could point me out to some awesome guide on wordpress rewrite rules. I have read a lot about them here, but there are so many different cases, I just want to understand how it works.

Update:

I ended up doing the following:

Setting the permalinks to /date/post tile/ format Setting the category base to /category/

This way pagination works for all posts and posts under a category. In my opinion it's not ideal because I can only get it to work if I have a category base, and the category base needs to be a fixed name.

So now I have:

All posts -> domain.com/blog/page/2
Category posts -> domain.com/category/category_name/page/2

Pagination works in both cases.

7
  • I think the custom structure of your permalinks is not good in Wordpress without custom rewrite rules: ottopress.com/2010/category-in-permalinks-considered-harmful
    – cybmeta
    Commented Jul 31, 2014 at 15:54
  • Good read but at the very top of that article it says that the problem has been fixed and that article is out of date.
    – gdaniel
    Commented Jul 31, 2014 at 16:08
  • ;) Yes I noticed that message in a second read. I've tested you custom permalink strucutre and it works here fine. I think you need to give us more information. Try a default theme and disable all plugins.
    – cybmeta
    Commented Jul 31, 2014 at 16:32
  • One question. Why is "blog" slug in the category URL? Have you set "blog" as the base for category URLs?
    – cybmeta
    Commented Jul 31, 2014 at 16:41
  • @cybmeta , good questions. I had it as the base category, but realized that that doesn't work because it's also the name of the page. So It's a mistype and I will update the question.
    – gdaniel
    Commented Jul 31, 2014 at 17:22

1 Answer 1

0

You have any News page? Check your page list. I think that there have a page which is taking the same category slug.

2
  • I do not. I made they urls wouldn't overlap. I only get 404 when I am trying to look at page 2, 3, 4 5... I don't get errors when looking at the category page itself.
    – gdaniel
    Commented Jul 31, 2014 at 18:11
  • Can we get your site url once? Commented Jul 31, 2014 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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