Custom post type pagination 404 fix?

Been trying to get this working all day but haven’t had any luck…

I have a custom post type called ‘news’ and an archive template (archive-news.php), here I’d like to show 2 posts with pagination, which works fine, until I try to go to the ‘next page’ (/news/page/2) which returns an error 404.

Any idea how to fix this / what I’m doing wrong?

I’ve literally spent all day trying to find a solution to this by searching Google and the WordPress forms, I found lots of solutions, none of which have worked so far.

My custom post type function: http://pastebin.com/uG1L6YNu
My rewrite rules print: http://pastebin.com/jbaDANYr

4 s
4

This is now working for me… for those of you having the same issue it turns out all the code was correct.

The problem was WordPress is setup to show 10 posts per page by default which clashed with my query (limiting it to 2 posts) to fix the issue I changed the WordPress setting (Settings / Reading in the admin dashboard) to 1.

Leave a Comment