Archived topic
Problem with pagination on category page
13 replies · Started by Pawel on July 28, 2021
Hello team,
I have a problem with pagination on one of my category pages.
My site has only two categories: blog and podcast.
The blog seems to work well, I noticed there is a specific page created for it with the URL /blog/. When I visit this page it displays the posts correctly and the pagination at the bottom of the page works well.
The problem is with 'podcast' category. This category does not have a special page created for it. I wanted to create one but I cannot use the URL /podcast/ for it as it is used already (I think there is a conflict between page URL and category URL).
So, when I visit the /podcast/, I can see the posts but when using the pagination, there is a 404 error.
I have noticed one more thing. When the address is /category/podcast/page/2/ the page is displayed correctly.
I hope this is not too confusing. Any thoughts on how to make the pagination work?
Thank you.
Hi there,
if you have a static page, post or image attachment that has the same slug as the category then you will run into conflicts.
If thats the case you should either edit the 'page' or the 'category' so they have a different slug.
If theres still an issue after doing that, then link me to the site so i can take a look.
Thanks, David. Just a few questions before I start breaking the website ;)
Do categories need to have pages?
If so, what URL will be displayed, the one from a category or page?
When I create a page for a category, how to set it to display posts from this category only?
Thanks in advance.
Do categories need to have pages?
No. And you shouldn't add them either. The theme will use the archive template for their display. Likewise you should not edit the Blog page that you have selected in Settings > Reading > Latest Posts display.
If so, what URL will be displayed, the one from a category or page?
It uses the Category Term Slug which you can see in the Posts > Category editor. This slug is what you must ensure is not duplicated elsewhere.
When I create a page for a category, how to set it to display posts from this category only?
As above, you should not create pages for them. Although you can create a static page and use a plugin like WP Show Posts to show the category term list, you will then need to do a lot of hoop jumping to manage the sites URL hierarchy.
If you need to add other content to a category archive then use the Block Element to hook in what you require.
Thank you David, I appreciate your help.
I think everything is set up correctly, I do not have a page for the podcast category, the page is displayed correctly but the pagination is not working (404 error).
Here is this page https://www.smartpolak.co.uk/podcast/
Any ideas on how to fix it?
First thing to try is to rebuild the permalinks.
Go to Dashboard > Settings > Permalinks and just click the Save Changes button ( no need to make any changes ). Then clear any plugin/browser caches.
unfortunately, it doesn't work
it looks like the pagination "doesn't know" that there is no word category in the permalink, so
/podcast/page/2/ -> this shows 404 but
/category/podcast/page/2/ -> is correct
Have you made any changes to the Permalink structure ?
If you haven't then aside from an SEO Plugin doing something weird it will most likely be because there is another Post, Page or Image attachment with the same slug.
No, I followed your advice, just clicked save.
Where do you have a link to your Podcast?
As the link needs to be: /category/podcast/
I don't have it, but when I type it manually to the web browser it works.
Then thats the link you need to be sharing or using. If for example you add a menu link to that archive it must be: /category/podcast/
I understand David, thanks a lot.
You're welcome