WP Query Is_404 set to true for page 2 and above in custom page template
-
WordPress version: 5.7.8
PHP : 8.XWebsite is using a custom theme with its own set of page templates.
In the URL provided, the page is using a custom page template and “paginate_links” was used to generate the pagination at the bottom of the page.
(It only has a page title and a custom page template – post content is empty)There are no issue in Page 1. However, upon click on page 2 and above, the system is 301 redirecting to the first page.
It appears the issue arises from the “handle_404” function in the “WP” class when the system is determining the value for $content_found.
E.g. URL : /course-search/2
After calling “WP Query” : “parse_query” function
– is_singular/ is_page : true
– is_404 : false
– post_content : “”In “WP” : “handle_404” function, it was looking for the “<!–nextpage–>” substring to determine that content does not exceed max no. of page. However, since there are no post_content in the page, $content_found will be set to false.
This causes the is_404 parameter to be set to true in the “WP Query” object.
As a result, “redirect_canonical” is not processing the request as intended.
The page I need help with: [log in to see the link]
- The topic ‘WP Query Is_404 set to true for page 2 and above in custom page template’ is closed to new replies.