#6603 closed defect (bug) (fixed)
bad next_posts_link when using a Static Front Page and custom permalink structure.
Reported by: | robanna | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.8 | Priority: | high |
Severity: | major | Version: | 2.5 |
Component: | Permalinks | Keywords: | has-patch tested commit |
Focuses: | 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 (3)
Change History (35)
#1
@
17 years ago
- 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.
#4
@
17 years ago
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.
#5
@
17 years ago
- Resolution set to worksforme
- Status changed from new to closed
That looks like it'll fix it.
Thanks-
#6
@
17 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
Not fixed, reopening.
#12
@
16 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.
#13
@
16 years ago
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.
#14
@
16 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.
#16
@
16 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...
#17
@
16 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?
#18
@
16 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?
#20
@
16 years ago
- Keywords has-patch needs-testing page added; "has-patch needs-testing" page" removed
#22
@
16 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)
#24
@
15 years ago
- 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.
#25
@
15 years ago
- Keywords tested commit added; 2nd-opinion needs-testing removed
patch still works, with a hunk.
#28
@
15 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.
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.