WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13156 closed defect (bug) (invalid)

Permalinks problem with 4-digits ID

Reported by: sashobg Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.9.2
Component: Permalinks Keywords: permalinks
Focuses: Cc:

Description

Hi,
I'm trying to change address of the type: http://www.domain.com/post_id with address of the type: http://www.domain.com/2010/04/sample-post/

When I do that change, I wanna use the popular Permalinks Migration Plugin, which would redirect visitors from the old to the new address.

But that's the problem: the plugin works perfectly with all posts, which have IDs of the type XX, XXX, XXXXX, but not with posts of the type XXXX - that is, 4-digit posts can't be redirected to the new address and I get a 404 error.

At the same time, I have a heavy database query, and for that reason I've reverted to the old variant, until the problem's solved.

To be concrete, here's an example:

http://testing2.slusham.com/31310 - it works, http://testing2.slusham.com/174 - it works, while

http://testing2.slusham.com/2775 , http://testing2.slusham.com/4525 and any other 4-digit posts do not work.

I've also tried the plugin Permalinks moved permanently, but it fails just in the same manner.

Change History (5)

comment:1 follow-up: @nacin5 years ago

WP realistically has no way of identifying that what it thinks is a year was actually once a post ID.

You'd have to hook in real early and perform the redirection or set the query vars yourself.

comment:2 in reply to: ↑ 1 ; follow-up: @sashobg5 years ago

Replying to nacin:

WP realistically has no way of identifying that what it thinks is a year was actually once a post ID.

You'd have to hook in real early and perform the redirection or set the query vars yourself.

Hi nacin, thanks for the reply. As I'm getting no reply in the forum, could you please just give me an example - how could I "hook in real early" (I guess I should set the redirection command in a given Wordpress file), and what do you mean by "setting the query vars myself" - as I'm using the panel to set the permalinks, but to no result.

Could you just please give me example - which file would I have to edit?

comment:3 in reply to: ↑ 2 @sashobg5 years ago

Replying to sashobg:

Replying to nacin:

WP realistically has no way of identifying that what it thinks is a year was actually once a post ID.

You'd have to hook in real early and perform the redirection or set the query vars yourself.

Hi nacin, thanks for the reply. As I'm getting no reply in the forum, could you please just give me an example - how could I "hook in real early" (I guess I should set the redirection command in a given Wordpress file), and what do you mean by "setting the query vars myself" - as I'm using the panel to set the permalinks, but to no result.

Could you just please give me example - which file would I have to edit?

And one more thing - if I use the structure /%postname%/%post_id%/ - it works, but then I get 404 on pages (not posts), which are usually www.domain.com/anything-here ?

comment:4 follow-up: @nacin5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Sorry, this isn't a support forum. There are many ways to do this. You can create a plugin that hooks into query, canonical, template_redirect, or even rewrite, to achieve what you're trying to achieve.

comment:5 in reply to: ↑ 4 @sashobg5 years ago

Thanks a lot. I'll try and get some help.

Note: See TracTickets for help on using tickets.