Ticket #6603 (closed defect (bug): fixed)
bad next_posts_link when using a Static Front Page and custom permalink structure.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | high | Milestone: | 2.8 |
| Component: | Permalinks | Version: | 2.5 |
| Severity: | major | Keywords: | has-patch tested commit |
| Cc: |
Description
I'm using the following link structure:
Front page displays A static page (select below)
- Front page: Home (www.apexprd.org)
- Posts page: News and Events (www.apexprd.org/news-and-events)
- Permalinks: /news-and-events/%postname%
In 2.3 this worked fine, I would get post pages under www/apexprd.org/news-and-events/page/2.
In 2.5, posts show up as www.apexprd.org/page/2 and not /news-and-events/page/2 as it should. The link for next_posts_link shows as /news-and-events/page/2 but when you click on it, it returns a 404 error.
If I change the permalink to anything but /news-and-events/ then it goes to the correct page
Example: permalink structure is /news-and-events/%postname% click on next_posts_link and you get a 404 error. everything else works as it should
Change the permalink structure is /news-and-event/%postname% (remove the 's' on events) click on next_posts_link and it goes to /news-and-events/page/2/ just fine but all of the post links look like /news-and-event/post-name
Could it be something in the rewrite.php file?
Attachments
Change History
- Summary changed from bad next_posts_link when using a Static Front Page. to bad next_posts_link when using a Static Front Page and custom permalink structure.
- Priority changed from normal to high
- Severity changed from normal to major
I am having the same problem. I would like to ask that the priority be increased on this as it will cause problems for numerous users and ultimately make many current sites malfunction.
Look at line 1002 of wp-includes/rewrite.php.
http://trac.wordpress.org/browser/tags/2.5/wp-includes/rewrite.php#L1002
Change that line from this:
$this->use_verbose_page_rules = false;
to this:
$this->use_verbose_page_rules = true;
Change false to true. With that done, go to the Settings->Permalinks page and click "Save Changes". Does that help? If so I can create a plugin that does that for you. I'll try to fix this properly for 2.5.1, but given that this setup works more by accident than design a proper fix might be difficult.
- Status changed from new to closed
- Resolution set to worksforme
That looks like it'll fix it. Thanks-
comment:6
Viper007Bond — 4 years ago
- Status changed from closed to reopened
- Resolution worksforme deleted
Not fixed, reopening.
comment:7
Viper007Bond — 4 years ago
(Not that I'm having this problem, just saying editing core != fixed.)
- Owner changed from anonymous to ryan
- Status changed from reopened to new
comment:11
dhardy — 4 years ago
Thanks I will check back when 2.7 is out ;-)
comment:12
mtekk — 4 years ago
Closed #7200 as a duplicate of this.
Also in case you did not notice, it is not the s that is causing it. What happens is if that first part of the permalink is the same as your posts page the links look correct but lead to 404s or a post that WordPress thinks redirecting you to is the most proper thing.
Hi Ryan - I've documented some of this issue in this thread: http://wordpress.org/support/topic/159406#post-802603 - Just posting as it might help with clues to resolving this issue.
comment:14
markmathson — 4 years ago
I was experiencing this issue, am using 2.6, and just fixed it using Ryan's recommended method described above.
So far I have not seen any negative side-effects.
comment:16
robanna — 3 years ago
This is still an issue in 2.7. I see that it's been changed from 2.7 to 2.8. I'm just saying...
comment:17
emartin24 — 3 years ago
ryan - I'm now facing this issue as well. You mentioned in your previous comment:
but given that this setup works more by accident than design a proper fix might be difficult.
I'm curious what you mean by "this setup works more by accident"? I have WordPress installed in /wordpress, a static home (/) and posts (/blog) page and configured permalinks to use the /blog prefix. This seems like it would be a common configuration.
I was going to try and look into the issue (past the solution you provided), but was curious what about this "configuration" that makes it hard to fix?
comment:18
emartin24 — 3 years ago
Attached a patch with a possible solution. It fixes my issue, but I'm not sure what possible side-effects it might have.
Anyone else willing to apply and test?
comment:19
emartin24 — 3 years ago
- Keywords "has-patch needs-testing", permalink, "static posts page", rewrite added
comment:20
emartin24 — 3 years ago
- Keywords has-patch,needs-testing,permalink, page, added; "has-patch needs-testing", permalink, page", removed
comment:21
emartin24 — 3 years ago
- Keywords has-patch,needs-testing,permalink,rewrite added; has-patch,needs-testing,permalink, "static posts page, rewrite removed
-
attachment
rewrite-new.patch
added
new patch - moved code from init() into page_rewrite_rules() function
comment:22
emartin24 — 3 years ago
Added a new patch that moves the check into the page_rewrite_rules() function. I had it in the init() function until I realized that it was being called on every request instead of just the necessary ones.
I did find one side-effect...if you make the change to use a static posts page and use a new permalink (adding /blog for example) to an existing site, by default, the old post url's will not work - they will just return a 404.
For example: mysite.com/my-post (before - will no longer work after change) mysite.com/blog/my-post (after)
comment:23
emartin24 — 3 years ago
- Keywords 2nd-opinion dev-feedback has-patch needs-testing permalink rewrite added; has-patch,needs-testing,permalink,rewrite removed
- Keywords dev-feedback permalink rewrite removed
I uploaded a new patch for this one. It changes the use_verbose_page_rules check, in such a way that constant strings at the beginning of the structure are ignored.
- Keywords tested commit added; 2nd-opinion needs-testing removed
patch still works, with a hunk.
comment:27
ryan — 3 years ago
- Status changed from new to closed
- Resolution set to fixed
comment:28
ryan — 3 years ago
That patch might be too aggressive in turning on verbose rules. /archives/%postname% probably shouldn't invoke verbose rules if archives is not a page. Hmmmm.
agreed, but it's meant to fix this, above all:
In 2.5, posts show up as www.apexprd.org/page/2 and not /news-and-events/page/2 as it should.
we'll work out how to dump these verbose rules after. it's not a very common use-case anyway...
opened #9824
see #9825 as well
comment:32
ryan — 3 years ago
Sounds good.
