Non existing blog pages are not redirected to 404

This is the default WordPress behaviour for pagination when using a custom query (where you feed in the paged value yourself) or in the index.php as it doesn’t realize there isn’t content to display on the XXXth page until it has already loaded the template, and then tries to run the WP_Query.

You can try adding logic that determines if $paged is set and no results are found, then throw the 404, which would look something like this:

header("HTTP/1.0 404 Not Found");
$wp_query->set_404();
require TEMPLATEPATH.'/404.php';
exit;

Leave a Comment