[wp-trac] [WordPress Trac] #5305: permalinks broken when article name is numeric
WordPress Trac
noreply at wordpress.org
Fri Sep 19 01:21:11 UTC 2014
#5305: permalinks broken when article name is numeric
--------------------------+-----------------------------
Reporter: thomask | Owner:
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future Release
Component: Permalinks | Version: 2.3.1
Severity: major | Resolution:
Keywords: has-patch | Focuses:
--------------------------+-----------------------------
Changes (by loushou):
* keywords: needs-patch => has-patch
Comment:
Seems to me that the only real solution to this problem is going to be to
prefix those numeric slugs with some alpha-dash-text of some sort;
otherwise, it will always get confused with any numeric value expected in
the permalink, and thus interpreted incorrectly. Prefixing it with
something as nondescript as '_' seems like the wrong solution, if for no
other reason than _123 just looks weird in a URL.
My solution simply prefixes a numeric slug with 'number-' (
http://example.com/number-123/ ). It is longer, and one could argue that
it is equally nondescript, but at least you know it is a number and it
does not get confused with expected numeric values in the permalink. This
is a blanket patch to the slug generation function, so it applies to all
post_types. As requested, this prefix allows any post type to work in any
of the standard permalink structures. As a party favor to all those devs
out there who love their filters (like me), I also have a filter on
'number-' that only gets called when it is needed. As a fallback to all of
this, if 'number-123' is not a nice permalink for a specific person, we
obviously still have the ability to manually override the permalink, just
not with anything numeric.
The original question also included a secondary issue, where apparently
post_name values that were prefixes to a category slug used to force the
category page to load instead of the post page. Based on the current
permalink class, this sounds like it is already solved and not even
possible any more. Even the old category slug - parent page slug collision
problem seems solved. This is because categories and tags are all prefixed
with a slug now. Matching clashes with that specified slug seems
unnecessary, so I assume we are just dropping that second request.
Thus I will attach the patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/5305#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list