Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to use a number for a post/page slug? I have tried to use e.g. '123' for my page slug, but each time WordPress converts it to '123-2'.

I'm guessing that any number is perhaps interpreted by WP as an ID. The number I want to use has nothing to do with post/page IDs. Can I get around this?

And yes, I have a good reason for using a number in stead of text in this case :-)

Edit: On a related, more general note, what restrictions are there on what you can put in a slug? I have found that I also can't use the + sign, though I've had that character in file names working just fine.

share|improve this question
add comment

4 Answers 4

It's only Pages where this is an issue. Posts are fine.

Seems like a bug to me, but regardless of whether or not it's a bug, you can not use numeric slugs on pages.

This is because number slugs like "/750/" interfere with posts years "/2010/" etc. and WordPress can't tell the difference.

If you save two pages to draft with the same number (say 750) then WordPress assigns the slug 750-2 to both. Upon publish, the first will stay 750-2 while the second will update to 750-3. There is no normal way to get slug 750 on a page as of 3.0

Update: http://core.trac.wordpress.org/ticket/11917 is the ticket that outlawed numeric slugs.

share|improve this answer
    
Not a bug, it is the way it was designed: core.trac.wordpress.org/ticket/11863 Mind you I don't particularly agree with that decision but it is what it is (if you or others don't like this then by all means go and comment on that track ticket expressing your opinion, or create another ticket to discuss the issue and post the link here.) –  MikeSchinkel Aug 19 '10 at 18:10
    
Regardless, the answer to the question is "No, not for pages. Only post slugs can be numbers. Pages will get a suffix." –  WraithKenny Jan 26 '11 at 2:16
add comment

Short answer: Yes, it's possible.

I had no problems to use a numbered slug, on concrete it was "56789". The -2 get's attached in case you have a slug already in use so it get's prefixed with a additional number.

It does generally work because a slug is a string and those numbers are a string as well, there is no interpreter running identifying your slug suggestion as number and then handling it in some other way as identifying as english words.

So you could browse your blog with the slug 123 and take a look what's there. Additionally you might take a peek in your database and look for the slug in the data itself, because it might get used in an attachment or so.

Update: I can have the slug 123 as well - just for the info. No problem with that number and this pretty permalink settings: /%year%/%monthnum%/%postname% .

share|improve this answer
    
did you perhaps get away with using such a high numeric value because it was a lot bigger than any possible page IDs for pages in your site? –  Rick Curran Aug 18 '10 at 11:50
    
Thanks for your answer. I did not define any page with the slug, so it's not a pre-existing slug issue. I did browse to the location (why didn't I think of that?), e.g. http://mysite/parent/child/123 and was shown the same content as for http://mysite/parent/child/ - it does not matter which number I put in there. –  avesse Aug 18 '10 at 13:43
    
What's the highest number for page ID? Tada: bigint(20) UNSIGNED has a maximum of 18 446 744 073 709 551 615 (dev.mysql.com/doc/refman/5.0/en/numeric-types.html). But well, maybe there is an esoteric number mode in slugs? –  hakre Aug 18 '10 at 15:23
add comment

I'm pretty sure it's not possible to use numbers for slugs due to the fact that the url rewriting process. I don't know the exact technical reason for it but I can see why it would need to prevent numeric slugs from matching the actual numeric page ID.

share|improve this answer
add comment

It's absolutely possible to use numbers for page slugs. However, adding a random number to the end of a page URL will always return that page (unless it matches another page's URL), since the rewrite engine tacks on numbers to match the ends of page permastructs to allow for pagination inside of posts. My guess is you have some post somewhere in your database that is using 123 as its slug (could be an image or other attachment, or a menu item, or something else). If you fix that, you should be able to set your page's slug to 123, and it will work. WordPress adds rewrite rules for each page individually, so it's not a problem of it not recognizing it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.