• In what circumstances does WP add ‘-2’ to a slug?

    I’d expect it to do so with duplicate post-names, but it also seems to do it with posts which begin with a number.

    I can usually work around it by prefixing the number, but it’ll be nice to know more.

Viewing 7 replies - 1 through 7 (of 7 total)
  • It should only add the -n to a slug when there is an existing Post or Page with the same title. Did you check the Trash for any such Posts/Pages?

    Thread Starter gulliver

    (@gulliver)

    Thanks, Esmi.

    In my original post I incorrectly used ‘posts’ rather than ‘pages’… it should have read ‘seems to do it with PAGES which begin with a number’.

    A further search suggests it’s ok to have posts with a numeric slug, but not pages – hence the appending of -2.

    I can’t think of any obvious reason why there should be an issue with numerical Page names. Can you give a list of steps to duplicate this using the default theme and no active plugins?

    Thread Starter gulliver

    (@gulliver)

    This link offers info.

    🙂

    Nice catch! Looks like numeric page slugs have been pretty much outlawed. 🙂

    Thread Starter gulliver

    (@gulliver)

    Oh well, such is life.

    I’m sufficiently grateful for what WP can do, to no longer get too-bothered about what it can’t.

    Thread Starter gulliver

    (@gulliver)

    Quick update…

    More reading suggests this isn’t an uncommon query, so for others who may stumble upon this later…

    The Allow Numeric Slugs plugin is designed to allow pages with numeric slugs – albeit at the cost of pagination for pages.

    From what I understand, the reason WP core code prevents such naming is to avoid rewrite and other issues where numeric slugs are confused with paginated pages and/or dates.

    But I won’t pretend to understand just why it applies to pages and not posts and custom posts.

    Personally, I’ll continue to try to not require numeric slugs – or to unobtrusively preface them accordingly (Example: my test pages are now ‘/test/t1/’, ‘/test/t2/’, etc rather than my preferred ‘/test/1/’ format.)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘what circumstances add '-2' to a slug’ is closed to new replies.