This WordPress plugin allows you to have Pages with a slug (URL) that is only a number.
Normally this isn’t allowed because it conflicts with the paging functionality, allowing you to split the content of a post or page into multiple views using
<!--nextpage-->. WordPress.com’s documentation on the functionality best describes how it works.
This plugin sacrifices that functionality in exchange for allowing numeric Page slugs.
Code contributions and bug reports are welcome via this plugin’s GitHub repository.
- Download from WordPress.org (0 downloads)
Thanks Viper…this bug was annoying the heck out of me since 2.5. I organize my photo gallery by year and it kept screwing it up. Works like a charm now!
Good to hear!
Although one precaution: if you have a ton of Pages with the same stub, it’ll increase the number of queries on those Pages by a bit as I guess it’s trying to figure out which Page was requested. They’re easy queries though, so it shouldn’t have too much of an impact. 🙂
Got here via wp-hackers mailing list… I’m interested in this plugin. Just one question about the stub problem that causes multiple DB queries: When does that occur? Specifically, would that occur if I had subpages like this:
The reason I ask is because the child pages aren’t the same but they all have the same parent page in the URL. Is that what causes the problem? Thanks.
Glenn on July 31st, 2008 at 2:48 PM wrote:
It’s a separate issue entirely: http://trac.wordpress.org/ticket/7443
Here’s an example:
When you visit any of those URLs, there is a good chance excess queries can occur. This is because WordPress is poorly tries to figure out which “mypage” you wanted (as there’s actually 3 Pages with the stub of “mypage”).
I have many, many Pages with the same single number stub but that have different parents. That was my issue.
This plugin alone should not cause any additional queries.
Thanks for the reply. Just curious, did you try Ryan’s diff that he added to that ticket?
Glenn on July 31st, 2008 at 8:10 PM wrote:
No, not yet although if I’m reading it correctly, all it does is allow the cache to help. If the Page hasn’t already been queried for and is known about, then I think it’ll still query.
I’ll test to see for sure later and if that’s the case, try and write my own patch as the code seems simple enough.
I’ve just tried the plug-in with WP3.0 and it doesn’t seem to make any difference. Have you tested it with the latest WP release?
Yep, it works fine. The only issue I ran into is WordPress kept suffixing a “-2”. Is that the issue you’re having?
I have the same issue as Rob Hyndman. Without the plugin, WordPress does allow numeric pages except that they are suffixed with a “-2”. The plug-in doesn’t make any difference.
This plugin actually is working in what it was designed to do, but WP 3.0 added some further validation. Before you could force a numeric ID by editing the slug but the page would never show up (this plugin fixed that by changing the rewrite rules).
Now WordPress has gotten smart and makes sure you always use a valid slug. My plugin needs updating to work around that second issue.
I just rewrote this plugin and committed the new version. It should work with WordPress 3.0+. Please test and confirm. 🙂
Thanks Alex. It looks like it works ok with WordPress 3.01.
Thank you so much for the fast update! It works for me in WordPress 3.01. 😀
Is there a new problem with WP3.0.4? I’m having trouble again with “-2” being added when I try to view the page (although the slugs are ok in the backend).
Not that I’m aware of. I’m using it on another one of my sites and haven’t noticed any issues.
The problem seems to have corrected itself after I changed the permalink structure. Not sure why.
I’m having the same issue as Rob above. I’m running latest version that came out this week, think it is 3.0.5. My permalinks changed from example.com/1 to example.com/1-2. All of the pages within example/1 also have this -2 added to their urls like example.com/1-2/page. Also, it appears from my google webmaster account that a 301 redirect is in place from example.com/1 to example.com/1-2. My wordpress permalink custom settings are set to /%postname%/
Anyone know what’s going on and how I can fix it?
Although I’ve used example.com/1 for over a year, so this wasn’t a problem for me previously. I’m hoping this plugin will help, but wary about installling/using plugins. Nonetheless, I’ll give it a try. If it fixes this problem, I’ll post again. thanks!
I installed and used this plugin. At first I was thrilled, because I saw that when I went to example.com/1 in my admin panel, I was able to republish it and all my permalinks returned as they were before. So, it did fix that problem for my Pages, but…
All of my Posts disappeared. The urls were getting 404 errors, even when I tried to republish them. I tried adding a new Post and published it, but when I went to the permalink for that Post, I got a 404 error.
So, unfortunately, I had to disable the plugin so that my posts show up. Could you look into this, and let me know if there is a bug, or if I need to change my own settings somewhere?
I really appreciate the help!!!
Just pushed out a new version that adds WordPress 3.3 support.
The plug-in has seemed to stopped working. For page permalink http://www.samplesite.com/parentpage/12345 all of the numerical sub-sub pages are populating the page http://www.samplesite.com/parentpage.
Of the couple dozen sub-parentpage pages with numerical permalinks all of them are populating the content from the parentpage 1 level up on the site.
Works fine for me with WordPress 3.3.
Try visiting Settings -> Permalinks to ensure the proper rewrite rules are in place (just visiting that page will clear the rewrite cache).
Setting is set to Custom Structure: /%postname%
I went to the Settings -> Permalinks site as you explained to (clear the rewrite cache). I did nothing on this site but open it. After I opened that Permalinks page I tried the pages and the all seem to work fine 🙂
I don’t think this plugin is compatible with that permalink structure, but I haven’t tested.
My installation went just fine and my permalink changed to a numeric permalink (without the annoying -2) but the page simply won’t load. I am getting a 404 error 🙁
Anyone else experiencing this?
Try visiting Settings → Permalinks. By visiting that page, you’ll force a rewrite rule cache flush which may resolve your issue.
Is this plugin working with WordPress 4.0? With the plugin activated, I was able to get a slug to be a number (in my case 86) but even after visiting Permalinks, I got a 404 error on actually trying to visit the page. Not only that, it tried to redirect on its way to 404, to 86gts, which I think I did save as many revisions ago. I tried deleting cache as well.
It should have worked fine with WordPress 4.0 (it did for me), but it did break with WordPress 4.4. I’ve just pushed out a fix along with a major rewrite that improves how it works.
failed on 4-digit numbers, eg mysite.com/0300/ – guessing wordpress thinks the 4 digits is a year value, eg 2016. can you disable that too, so your plugin does its job better?
I have pages that are just titled by year so the slugs would be /2018/ or /2017/ etc. I got the page to allow the four digits as the slug but it renders 404 when I try to view it. Has there been any headway made to force it to render?
Hi there! I installed your plugin and worked, but now 2 pages are keeping the “-2” & “-4” what am I doing wrong, setting the page as password access only for the first week or 2?