Homepage has Paged Pages that should not exist, like /page/2/ and on to /page/99999/
The backstory is I noticed the homepage was generating infinite paginated pages. This is a custom built theme.
I was using index.php and WP_Query to create 2 small 5 post loops. I figured WP_Query was pulling all of the qualifying posts and then limiting to the most recent 5, so I switched to get_posts with a foreach loop, since my understanding is that doesn't fetch all the posts, only the ones you ask for (and therefore no need for pagination). This didn't solve the issue.
Then I realized that the Settings > Readings were set to show Latest Posts, which explained why Yoast was auto-adding a "next" schema with a link to page/2/ though it shouldn't exist. By changing that to a static page and moving index.php to front-page.php, that killed off the "next" schema.
However, you can still manually go to /page/2/ on to /page/24893/ and so forth, and it still loads the same posts as page one instead of giving off a 404 error.
The problem here is that with the "next" schema having been there, Google could be indexing all that bloat infinitely. It's not, but it's a potential. The real problem is it's driving me nuts and I don't want this to be the case that those pages exist. Since they were previously exposed I'd like them to 404 now.
Every Wordpress site I've checked that I can think of that has a static homepage has the problem.
Does anybody know what's triggering this? I'm doing small static loops with get_posts and have no pagination setup and it's set to a static front-page.php.
Thanks
Topic homepage pagination Wordpress
Category Web