• WordPress version: 5.7.8
    PHP : 8.X

    Website 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]

Viewing 2 replies - 1 through 2 (of 2 total)
  • As its custom theme we’re not sure about what code used for WP_Query but I think you can check by resetting permalinks in settings->permalinks and just save the settings. If this doesnt work, may be the next step would be to check with conflict with any plugin.

    Thread Starter ksytan

    (@ksytan)

    The WP_Query/ WP was referring to the “class-wp-query.php”/ “class-wp.php” files in the WP default package. No changes have been made to both files.

    I have tried the permalinks suggested but it still does not work.

    The issue should not be due to plugins as there are no plugins used in the page itself.

    Note: The issue had only arisen after the WP upgrade to 5.7.8. Prior to this, the site was using WP 5.4 and the issue does not exist.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP Query Is_404 set to true for page 2 and above in custom page template’ is closed to new replies.