[wp-trac] [WordPress Trac] #35544: Extra page issue after 4.4 update
WordPress Trac
noreply at wordpress.org
Wed Jan 20 13:48:25 UTC 2016
#35544: Extra page issue after 4.4 update
--------------------------+-----------------------------
Reporter: Milamber | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version: 4.4
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Prior to 4.4 was able to append extra pages to the end of posts with the
following:
{{{#!php
<?php
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.
{{{#!php
<?php
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:
https://core.trac.wordpress.org/ticket/35344#comment:16
https://core.trac.wordpress.org/ticket/35344#comment:34
Observation:
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35544>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list