#35344 closed defect (bug) (fixed)
Strange pagination issue on front page after 4.4.1 update
Reported by: | northeme | Owned by: | dd32 |
---|---|---|---|
Milestone: | 4.4.2 | Priority: | normal |
Severity: | normal | Version: | 4.4.1 |
Component: | Canonical | Keywords: | has-patch needs-unit-tests needs-testing fixed-major |
Focuses: | Cc: |
Description
If a custom post type or blog listing page is set as a front page, pagination URLs don't work properly since 4.4.1 - E.g. /page/2, /page/3. However, it works just fine if permalinks set to Default or listing page unselected at Settings > Reading > Front Page.
There was no problem with front page pagination until 4.4.1
Attachments (2)
Change History (79)
#2
@
9 years ago
- Component changed from General to Query
- Milestone changed from Awaiting Review to 4.4.2
Thanks for the bug report!
I can reproduce the behaviour you're describing. We'll get this fixed up. :-)
#3
@
9 years ago
I appreciate your swift reply @pento ! It's good to know that you'll look into that, you definitely made my day :)
#4
@
9 years ago
- Keywords has-patch needs-unit-tests needs-testing added
35344.diff is a first pass at fixing this, though given the edge cases we've encountered in this code, it'll need some careful consideration.
#5
@
9 years ago
No doubt that it'd need a lot of testing. Thanks for the heads up. At least I can let know our theme users who are having this issue to stick to Version 4.4 or try to fix this manually.
#6
@
9 years ago
So this is actually quite a fun weird bug.
The fix for #35031 calls get_queried_object()
which causes $wp_query->queried_object
to get set, That being set then triggers a few rules in redirect_canonical()
which specifically deal with page-on-front (which must've been broken previously?).
Ultimately it comes down to the fact that canonical doesn't know how to deal with paged posts when they're on the front-page, it specifically excludes is_front_page()
- the problem being I can't see where it's supposed to be handled instead.
35344.2.diff makes it work for me, by properly creating the canonical URL.
It seems like it was probably a 4.4 regression that's caused $wp_query->queried_object
to be false/unset at the time that redirect_canonical()
gets called.. I'm not sure how/what happened there..
#8
@
9 years ago
I tested @dd32's patch and it worked to restore CPT pagination on my 4.4.1 install.
This CPT pagination issue was reported in the forums by several users running Espied with its static front page set to display Jetpack's portfolio custom post type and also affects other themes that use the portfolio CPT on the front page, like Illustratr. The patch worked well for both themes.
#11
@
9 years ago
I feel I should mention that crazy if in 35344.2.diff is built from the existing one there, plus the canonical rule far above which is matching to create the issue.
I'm certain it could probably be made a lot cleaner by using get_queried_object()
and/or get_queried_object_id()
.
This ticket was mentioned in Slack in #core by dd32. View the logs.
9 years ago
#16
follow-ups:
↓ 28
↓ 44
↓ 46
↓ 51
@
9 years ago
I can confirm changing the wp-includes/canonical.php lines 264-270 from this
<?php // Post Paging if ( is_singular() && ! is_front_page() && get_query_var('page') ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }
to
<?php // Post Paging if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $page = get_query_var( 'page' ); if ( is_front_page() ) { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); } else { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); } $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }
fixes the issue.
I guess this will be part of the next update?
Thank you.
#17
@
9 years ago
I've also tested the patch and confirms it fixes this issue. Several users of Portfolio Press (theme in repo) have started to encounter this bug.
#18
@
9 years ago
I applied the above fix to canonical.php and for us it did not fix the issue. Using InTouch template (ThemeForest).
#21
@
9 years ago
- Owner set to dd32
- Resolution set to fixed
- Status changed from new to closed
In 36237:
#22
@
9 years ago
- Component changed from Query to Canonical
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening for 4.4.2 work.
If you're here for the issue where capitalisation issues cause the front page to get stuck in an infinite loop, see #21602
#24
@
9 years ago
needs-unit-tests
;-)
Hey, I didn't remove it, it still needs them :) (Just good luck working out why the existing unit test for it fails to catch that it was broken)
#26
@
9 years ago
Actually it turns out that the unit tests kind of do cover this.
By changing from isset($wp_query->queried_object)
to get_queried_object_id()
it triggered a unit test failure, but that failure was then fixed by the main part of the patch.
[36238] adds a few more unit tests that cover the behaviour of [36237]
This ticket was mentioned in Slack in #core by asad. View the logs.
9 years ago
#28
in reply to:
↑ 16
@
9 years ago
- Resolution set to worksforme
- Status changed from reopened to closed
Replying to BackuPs: Changing the wp-includes/canonical.php lines 264-270 worked perfectly for me! I'm running WT Tera News on my blog, and I had this pagination issue since the 4.4.1 update. Deactivated all plugins at first to try to find the culprit (pagination problems have been often linked in my case, to the cache plugin I use or the Easy Digital Download plugin), but that didn't work.
Thanks to this workaround in the canonical.php file, pagination is back on the homepage.
Thank you for sharing!
I can confirm changing the wp-includes/canonical.php lines 264-270 from this
<?php // Post Paging if ( is_singular() && ! is_front_page() && get_query_var('page') ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }to
<?php // Post Paging if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $page = get_query_var( 'page' ); if ( is_front_page() ) { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); } else { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); } $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }fixes the issue.
I guess this will be part of the next update?
Thank you.
#29
follow-ups:
↓ 30
↓ 31
@
9 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
Is this going to make it in 4.4.2? Its causing a ton of unneeded support tickets from my buyers.
#30
in reply to:
↑ 29
@
9 years ago
Replying to contempoinc:
Is this going to make it in 4.4.2? Its causing a ton of unneeded support tickets from my buyers.
Totally hope so. I'm getting a whole lot as well.
#31
in reply to:
↑ 29
@
9 years ago
Replying to contempoinc:
Is this going to make it in 4.4.2? Its causing a ton of unneeded support tickets from my buyers.
Yes, please release it under 4.4.2. I'm getting a lot as well.
#32
follow-up:
↓ 43
@
9 years ago
A fix for this will be included in 4.4.2. There is no ETA for release yet. +1's are not helpful right now, we understand it's an issue for many people.
#34
follow-ups:
↓ 37
↓ 38
↓ 39
↓ 40
↓ 42
↓ 54
@
9 years ago
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
#37
in reply to:
↑ 34
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
This worked for me! The canonical.php fix earlier did not, so I reverted it back to the 4.4.1 version. This new query.php did correct the issue immediately.
#38
in reply to:
↑ 34
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
Yes, pagination works on the homepage with the updated query.php file.
#39
in reply to:
↑ 34
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
Yup, that definitely fixes the issue!
#40
in reply to:
↑ 34
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
Fixed my issue. Thanks.
#42
in reply to:
↑ 34
;
follow-up:
↓ 52
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
This fixed the front page issues, but it looks like I'm still having the same problem on category pages.
#43
in reply to:
↑ 32
@
9 years ago
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
I did it.
But it’s still not working.
#44
in reply to:
↑ 16
;
follow-up:
↓ 45
@
9 years ago
Replying to BackuPs:
I can confirm changing the wp-includes/canonical.php lines 264-270 from this
<?php // Post Paging if ( is_singular() && ! is_front_page() && get_query_var('page') ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }to
<?php // Post Paging if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $page = get_query_var( 'page' ); if ( is_front_page() ) { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); } else { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); } $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }fixes the issue.
I guess this will be part of the next update?
Thank you.
This helped me.
Thank you)
#45
in reply to:
↑ 44
@
9 years ago
I also tested this, it fixes the problem completely, don't know if it breaks anything else yet, but it seems to be a good fix so far.
#46
in reply to:
↑ 16
@
9 years ago
Replying to BackuPs:
I can confirm changing the wp-includes/canonical.php lines 264-270 from this
<?php // Post Paging if ( is_singular() && ! is_front_page() && get_query_var('page') ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }to
<?php // Post Paging if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $page = get_query_var( 'page' ); if ( is_front_page() ) { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); } else { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); } $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }
I have tested this and it fixes the problem form me, although I don't know if doesn´t breaks anything else...
#47
@
9 years ago
I tried this. https://core.trac.wordpress.org/ticket/35344#comment:16 by BackuPs
Not working for me.
How can i use patches by @dd32 and @pento ?
Why is that not working?
The strange thing is that, pagination in my theme is working fine on localhost, without editing any core files.
but on server when i uploaded my theme, and tested online then, its not working.
Any idea!
#48
follow-up:
↓ 49
@
9 years ago
@faqeer Follow the instructions here: https://core.trac.wordpress.org/ticket/35344#comment:34
Thanks to everyone who has +1'd various fixes here, please stop now :) The fix will be available in 4.4.2 when it's released.
#49
in reply to:
↑ 48
@
9 years ago
Replying to dd32:
@faqeer Follow the instructions here: https://core.trac.wordpress.org/ticket/35344#comment:34
Thanks to everyone who has +1'd various fixes here, please stop now :) The fix will be available in 4.4.2 when it's released.
Now it worked.
When will be 4.4.2 releasing.
#51
in reply to:
↑ 16
@
9 years ago
Replying to BackuPs:
I can confirm changing the wp-includes/canonical.php lines 264-270 from this
<?php // Post Paging if ( is_singular() && ! is_front_page() && get_query_var('page') ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }to
<?php // Post Paging if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) { if ( !$redirect_url ) $redirect_url = get_permalink( get_queried_object_id() ); $page = get_query_var( 'page' ); if ( is_front_page() ) { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); } else { $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); } $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); }fixes the issue.
I guess this will be part of the next update?
Thank you.
This also fixed the pagination issue I was having using the Ultimate Auction Pro plugin. Thanks!
#52
in reply to:
↑ 42
;
follow-up:
↓ 53
@
9 years ago
Replying to Ipstenu:
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
This fixed the front page issues, but it looks like I'm still having the same problem on category pages.
Also experiencing this issue, and the fix is not working on category, or archive pages, i.e., any page that is not the front page.
#53
in reply to:
↑ 52
@
9 years ago
Replying to ZaneMatthew:
Replying to Ipstenu:
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
This fixed the front page issues, but it looks like I'm still having the same problem on category pages.
Also experiencing this issue, and the fix is not working on category, or archive pages, i.e., any page that is not the front page.
I believe your issue may be different than the one covered here, potentially related to #35482. I've sent you an email to gather a few extra details.
#54
in reply to:
↑ 34
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to dd32:
For those still experiencing problems in 4.4, Can you please try to replace your wp-includes/query.php file with this one and let me know if that helps?
I am now running with this query.php and 35344.2.diff but I still have the problem. /page/2 redirects to / and higher pages page/3, page/4 etc. do not redirect but show the front page.
#55
@
9 years ago
I tested it. I can reproduce the issue with Version 4.4.1 and after replacing the file, the issue is resolved.
#56
follow-up:
↓ 59
@
9 years ago
- Resolution set to fixed
- Status changed from reopened to closed
@chriscamplejohn I'll email you shortly to get a few more details about your site and figure out what problem you're experiencing.
#57
@
9 years ago
On a multisite with two sites on Illustratr with a Portfolio front page. Site 1 has Polylang running and (strangly) worked fine all along while site 2 without Polylang showed the pagination issue. Applying https://core.trac.wordpress.org/attachment/ticket/35344/35344.2.diff solved the issue on site 2 while site 1 kept working like before.
#58
@
9 years ago
Partial fix for me with the update to canonical.php. Issue fixed on the home page but page 2 onwards now all point to /page/2/. I also don't see the 'recent posts' link allowing me to go forward again.
Using the new query.php file had no effect.
#59
in reply to:
↑ 56
@
9 years ago
Replying to dd32:
@chriscamplejohn I'll email you shortly to get a few more details about your site and figure out what problem you're experiencing.
Experiencing the same thing with @chriscamplejohn. Already replaced my query.php file and applied the canonical.php patch and it only fixed the URL I see in the browser (meaning the redirect to home/front base page stopped) but the posts I get from query_posts() are still the same throughout /page/2/ ... /page/3/ ... and so on.
I see that the 'paged' (instead of 'page') query_var is being received by my page template but I think it's the query_posts() function that may not be handling properly the arguments I pass to it.
But on the other hand, isn't it also supposed to be the 'page' query_var that should be filled, instead of the 'paged'?
#60
follow-up:
↓ 64
@
9 years ago
It seems to be that the remaining issues being experienced is this scenario, which is sounding like a combination of #35482 and this ticket.
- Static page on front, no posts page defined
query_posts()
or$wp_query = new WP_Query()
used within the template to display the first page of posts/page/2/
would then load page 2 of the posts index with no static page in sight.
The problem I face, is that /page/2/
should NOT be the archive of posts, it should be the second page of the static home page (You can paginate posts/pages using the <!--nextpage-->
tag in your content).
This ticket was mentioned in Slack in #core by dd32. View the logs.
9 years ago
#63
@
9 years ago
None worked for me :(
I replaced the file but what it does is when I click on next page, it highlights that page but still shows page 1 content.
Before the change, it shows page 1 and highlights page 1 still even if i click on any other pages
Please help
#64
in reply to:
↑ 60
@
9 years ago
Replying to dd32:
It seems to be that the remaining issues being experienced is this scenario, which is sounding like a combination of #35482 and this ticket.
- Static page on front, no posts page defined
query_posts()
or$wp_query = new WP_Query()
used within the template to display the first page of posts/page/2/
would then load page 2 of the posts index with no static page in sight.The problem I face, is that
/page/2/
should NOT be the archive of posts, it should be the second page of the static home page (You can paginate posts/pages using the<!--nextpage-->
tag in your content).
It's more like this in my case:
- Static page on front using a page template that lists:
- A limited number of custom posts and
- A paginated list of native wp blog posts
query_posts()
to retrieve the CPT's and the native posts.)
- Another separate page assigned as the blog posts page
/page/2/
would load the same set of CPT's and the 2nd page of the native posts index.
I'm not sure if I explained it clearly enough, but you can check the site here: http://philpropertyexpert.com
I ended up just rolling back to 4.3.2 for now just to get it working again. (4.4 has the same issue.) But before the rollback, /page/2/
and onwards would display the same 1st page of the native posts index.
This ticket was mentioned in Slack in #bbpress by netweb. View the logs.
9 years ago
#68
@
9 years ago
- Keywords fixed-major added
- Resolution set to fixed
- Status changed from reopened to closed
I'm re-closing this ticket. A lot of the initial issue was fixed and is fixed for those that are testing with 4.4.2 files. If you're still experiencing issues like those in comment 60 and on, please follow #35689 as we'll be working on the issues there.
#69
@
9 years ago
Solution #34 (replacing the wp-includes/query.php file) worked for me (WP ver. 4.4.1). The other solution just made my blog go blank.
Thank you for this fix!
#70
follow-up:
↓ 74
@
9 years ago
Well non worked for me, so had to revert back to WP v4.3.2
I will never upgrade to new release until after a month or 2
This ticket was mentioned in Slack in #bbpress by casiepa. View the logs.
9 years ago
#72
follow-up:
↓ 75
@
9 years ago
Still having this problem on 4.4.2 with or without 35344.2.diff applied.
The query.php in 4.4.2 is way too different to apply 35344.diff.
In my case this bug only affects posts on a static front page, and instead of redirecting to the homepage it strips the page number from the URL and tries to load sitename.com/page/ which, in turn, returns a 404.
Following up in new bug #35847
#74
in reply to:
↑ 70
@
9 years ago
Replying to isaac2k2:
Well non worked for me, so had to revert back to WP v4.3.2
I will never upgrade to new release until after a month or 2
Hi,
is there an easy - maybe automated - way to revert back?
Thanks for your time
Lars
#75
in reply to:
↑ 72
@
9 years ago
Replying to finomeno:
Still having this problem on 4.4.2 with or without 35344.2.diff applied.
The query.php in 4.4.2 is way too different to apply 35344.diff.
In my case this bug only affects posts on a static front page, and instead of redirecting to the homepage it strips the page number from the URL and tries to load sitename.com/page/ which, in turn, returns a 404.
Following up in new bug #35847
Sounds like my problem. Did you solve this issue?
Thanks for a short relpy!
Lars
I forgot to mention that pagination links redirect to homepage instead of redirecting to 404 page. In other words, pagination links should be working fine yet I couldn't find out the reason why it's redirecting back to home.