Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#35544 closed defect (bug) (duplicate)

Extra page issue after 4.4 update

Reported by: Milamber Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Canonical Keywords:
Focuses: Cc:


Prior to 4.4 was able to append extra pages to the end of posts with the following:

add_action('template_redirect', 'custom_content_one');
function custom_content_one() {
        global $post;
        $content = "\n<!--nextpage-->\nExtra page v1";
        $post->post_content .= $content;

Since the release of 4.4 the above code no longer works. I tried leveraging the new content_pagination filter as well as hooking into the_post but the issue remains.

add_filter('content_pagination', 'custom_content_two', 10, 2);
function custom_content_two($pages, $post) {
        if ( in_the_loop() && 'post' === $post->post_type ) {
                $content = "Extra page v2";

                $pages[] = $content;
        return $pages;

add_action('the_post', 'custom_content_three');
function custom_content_three() {
        global $multipage, $numpages, $pages;
        $content = "Extra page v3";

        $multipage = 1; // ensure post is considered multipage: needed for single page posts
        $numpages++; // increment number of pages
        $pages[] = $content;

All of the above methods add the additional page to the post's pagination but visiting the extra page triggers a 404 error (if redirect_canonical is not disabled redirects to page 1 of the post).

However, the issue only occurs on posts that already have multiple pages. If the page does not, then the extra pages function as intended.

Pagination is disabled and I have tried both of the following fixes with no change in behavior:

On posts that already contain multiple pages, $wp_query->queried_object is empty on the additional page, while it's populated on posts that only contain one page.

Change History (3)

#1 @Milamber
5 years ago

The above should say that permalinks are disabled, not pagination.

#2 @Milamber
5 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #35562.

#3 @netweb
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.