I've got a page called Blog. In the Settings -> Reading
I've set my Blog page
as Posts page
. In the menu when I click on the Blog
link the posts are loaded correctly and pagination works, so far so good. All the info is coming from the home.php
template.
I'm using my own pagination code that generates the pages looking at max_num_pages and paged
params. In short it generates correct amount of pages with the correct links.
However, when I test a non-existent blog page. For example there are 5 pages exist and I type blog/page/6
it doesn't get redirected to 404, instead it seems to fall back to the else statement of the main if(have_posts())
.
I've tested the category paginated pages that use the same pagination code, they work correctly: non existing category pages of type category/<category_name>/page/2
are redirected to 404
template.
I can't think of anything why the main blog 'paged pages' that don't exist won't redirect to 404.
I would hugely appreciate any tips and help.
Many thanks, Dasha