WordPress.org

Ready to get started?Download WordPress

Forums

Pages with identical slugs (7 posts)

  1. robjhyndman
    Member
    Posted 4 years ago #

    I have a site where I use pages and subpages with numerical slugs. For example site.com/1, site.com/1/1, site.com/2/1, etc.

    This used to work fine, but after upgrading to WP3.0, whenever I edit a page, the slug is automatically changed to be unique (e.g., 1-2 instead of 1).

    Is there any way I can retain the identical slugs?

  2. wprelief
    Member
    Posted 4 years ago #

    You can try manually editing the slugs before you save the posts... It would be interesting to hear if this actually works for you

  3. robjhyndman
    Member
    Posted 4 years ago #

    I've tried that. If I try to manually change the slugs back to what I want, the changes are not retained. This used to be the case only when there was another slug at the same level (e.g., you couldn't have two top-level pages with the same slug). But now it seems to be the case regardless of where the pages are in the hierarchy.

  4. wprelief
    Member
    Posted 4 years ago #

    I am not sure what to tell you other than WordPress must have found some very compelling reason to make sure that the slugs are always unique. Sorry to not have a better answer for you.

  5. robjhyndman
    Member
    Posted 4 years ago #

    I've discovered that the problem is not identical stubs but numerical stubs. Apparently WP no longer allows purely numerical stubs. There is a bug report at http://core.trac.wordpress.org/ticket/5305 and a supposed fix at http://wordpress.org/extend/plugins/allow-numeric-stubs/. But the bug report is for an old version (2.3.1) and I've been using numeric stubs with 2.9.2 with no problems. Also, the plugin does not seem to fix the problem with WP3.0.

  6. robjhyndman
    Member
    Posted 4 years ago #

    Update. This is the change that caused the problem: http://core.trac.wordpress.org/changeset/13424
    The problem goes away if I manually revert to the original code, although this is a bit hacky for my liking. It would be nice if someone produced a plug-in to do the same, but that is beyond my php skills.

  7. wprelief
    Member
    Posted 4 years ago #

    The only way I see it being possible to capture this is right after it happens, with the pre_post_update action.

    You would have to access the variables (this is VERY hackish and not proven):
    global $post_name;
    global $postarr;

    //get the pre-defined slug from the $postarr
    //set the $post_name to the slug you want

    This may or may not work.

Topic Closed

This topic has been closed to new replies.

About this Topic