WordPress.org

Ready to get started?Download WordPress

Forums

Four Digit Permalink Problem (3 posts)

  1. Dennis Whiteman
    Member
    Posted 5 years ago #

    I believe this already logged as bug ID 7467 in the Trac system for WordPress, but I need to get this working before 2.7 and it is as yet unresolved. So if someone could point me in the right direction, I might be able to fix this and contribute it back to the source.

    Having migrated some posts from another system, I have a custom permalink system to preserve the old URLs as much as possible:

    /content/%postname%/

    During the migration, I've used an exist ID number as the postname so the permalinks are like this:

    http://www.site.com/content/1/
    http://www.site.com/content/10/
    http://www.site.com/content/100/
    http://www.site.com/content/1000/
    http://www.site.com/content/10000/

    All of those work except the one with four digits where postname = 1000. I can use this URL (http://www.site.com/?p=1000) with permalinks turned off and it displays the correct post, but not the one using the custom permalink structure. Since I have about 42K posts, that means that roughly 20 percent of them return 404 not found pages.

    I would think this problem originates in /wp-includes/rewrite.php and possibly here in lines 16-18...

    if (strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') {
    		return;
    	}

    Anyone with experience hacking the original source that thinks this would fix the problem or who has a better idea for solving this issue until it's officially resolved?

    Thanks,

    Dennis

  2. Dennis Whiteman
    Member
    Posted 5 years ago #

    I'm still working on this problem, but it appears that the custom permalink structure I entered is being ignored in favor of providing a year-based permalink structure so...

    http://www.site.com/content/1000/

    ...doesn't work because I don't have any posts added in the year 1000. However, I do have posts from 2007 so this displays posts from the year 2007...

    http://www.site.com/content/2007/

    ...not post ID 2007. Obviously a bug of some kind that I working to fix at least on my installations, but I hope this gets resolved in the trunk...

    Dennis

  3. Dennis Whiteman
    Member
    Posted 5 years ago #

    Just as an addendum for anyone trying to solve this problem in the future, there are several existing bugs that have been filed on this issue.

    In my case, I'm able to work around it by using post_id instead of postname as the slug.

    /content/% post_id%/

    This does not affect pages and only affects about 20 or so posts that I'm not going to directly link to anyway.

    Dennis

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags