#13471 closed defect (bug) (fixed)
Pagination in Blog Post Won't Display Past Page 1
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.0.2 | Priority: | normal |
Severity: | critical | Version: | 3.0 |
Component: | Canonical | Keywords: | has-patch |
Focuses: | Cc: |
Description
I've posted a multi-page post a few days ago, and that post is paging, but the last couple days, every multi page post will revert to showing only page one.
Both posts use the <!--nextpage--> tag in source. Both posts show the pages numbers at the bottom of page 1. Both posts have the correct link URL, ....postname/2/ ..postname/3/ etc.
However when clicking on any of the pages, only the first page is returned. This only effects recently entered new posts, as a previous post from a few days ago, still pages fine.
I will attempt to repost the OLD content in a new post and try to find the difference and return my findings.
Attachments (2)
Change History (21)
#2
@
15 years ago
Work-Around
I've resorted to using just %postname%/ in my custom permalink settings and since there is only one argument before the page number. sitename.com/page-title-here/##/ this works.
#3
@
15 years ago
- Keywords permalink added
Thank you for posting the workaround. I've been going nuts. I'm amazed this isn't a more prevalent problem.
#4
@
15 years ago
Yes been chasing this today :(
The cause is the fix applied in r13781 of wp-includes/canonical.php which added the following code to fix #11807
} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) { $category = get_term_by('slug', get_query_var('category_name'), 'category'); $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids')); if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) ) $redirect_url = get_permalink($wp_query->get_queried_object_id());
The problem is that get_term_by doesn't support hierarchies so when passed a second level category e.g. cars/sports it will fail and hence the rewrite is performed loosing the page information.
The following fixes this but I'm not 100% that the intention is to only check the last category in the hierarchy, although with our data anything more would appear to fail. This may indicate that additional fixes are required but anyway:-
$category = get_term_by('slug', end( explode( '/', get_query_var('category_name') ) ), 'category') ;
#6
@
15 years ago
Increased severity as this causes major site breakage for those that use this permalink structure.
#8
@
14 years ago
- Keywords needs-patch added; pagination nextpage permalink removed
- Milestone changed from Awaiting Review to 3.0.2
#10
@
14 years ago
- Keywords has-patch needs-feedback added; needs-patch removed
Patch worked on r15483 (3.0.1).
#14
@
14 years ago
- Keywords commit removed
- Owner set to nacin
- Status changed from new to reviewing
Actually, no need for the conditional. explode() will always return an array, with a size of one if there's no child categories.
Also, end(explode()) triggers an E_STRICT here, which means it likely throws a fatal on PHP 5.0.5 and 4.4 (#14160). Solution is to do it in two steps, or awkwardly assign a variable inside, like end( $foo = explode(...) )
.
Patch attached, untested, should have proper logic.
#16
@
14 years ago
As an additional enhancement to this: It should actually confirm that category_name is equal to the proper path. Otherwise, /fake-category/real-category/ will not redirect to /real-parent/real-category/.
Ok, here is the scoop. If the post is in a nested category, the pagination fails. If the the post is in a top level category the post paging will work. It's like the URL will only take 2 segments, category and post title.
Now this all is because I am setting my permalinks to /%category%/%postname%/
And this works for generating multi level categories. However if there is a nested category, then the PAGE number gets lopped off.
And sure enough, if I resort to one of the default permalink setting, the pagination works.
So what is wrong with using: %category%/%postname%/ with pagination?