A common problem that you’ll probably face with when using custom post types is your pagination not working correctly.
That is, when you check the listing page for your custom post type, have pagination set up, and click on let’s say “Page 2”, all you get is a 404 – Page Not Existing – error.
What is behind this problem and most importantly, how to solve it? Do you really need to dig into the code or even WordPress core files?
Fortunately, there is a real simple solution, that works most of the time.
I ran into a very nerve-racking problem the other day: I couldn’t see the 2nd page of the recipe listing on one of my recipe blogs. Everything worked fine, the first page of the listing was displaying correctly, also the permalink looked OK when hovering my mouse over the 2nd page link. But when clicking on it, I got a 404 error.
I dig into Google to solve the problem, but all that I found was changing source code here and there.
As my theme was working quite well otherwise, I assumed the problem was not in the source code but somehow with the custom post type, Recipes in this case.
Let’s suppose you have a recipe blog, with a custom post type Recipes. Please note that the same situation may arise with any kind of custom post types, I’m using recipes only as an example here.
As you have a list of recipes, it’s obvious you want to display them in a listing page. That is, list all your recipes.
The most convenient way for this is to use a WordPress page, and display the listing there. Most WordPress themes have a page template for this.
If you are SEO conscious, chances are that the title and the url for that page will be also recipes for this page.
So you have a custom post type called “Recipes”. You also have a “Recipes” page, let’s say with a url example.com/recipes.
In this case, the 2nd page for this listing will use the permalink example.com/recipes/page/2, and this will cause the problem. It will somehow collide with the custom post type setting.
According to rafaelxy, to whom I’m really thankful for this simple solution
“Basicly, you CANT have a PAGE and a CUSTOM POST TYPE with the same name. If you do, the permalink rewrite rules will get confused and trigger a 404.”
So the solution is really simple, and it shouldn’t hurt your SEO either.
Just go and rename your page that you use for the listing.
In my case, I just used the title “Hungarian Recipes” instead of “Recipes“. But I could have just used “All Recipes“, “Recipes with Pictures“, “Recipe Listing” instead as well. You name it.
There might be some exceptions when the pagination problem with WordPress custom post types requires a deeper digging into the code. But in my opinion, in 95% of all cases this simple solution will fix your problem.