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:
- permalink custom structure: /%category%/%postname%/
- I have a page named "blog"
- I have the reading settings making the page "blog" the Posts Page.
- I'm only using the index.php to list all posts
- 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.