#43593 closed defect (bug) (invalid)
Permalink setting of /%postname%/ appends -2 to all posts without titles
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.9.5 |
Component: | Permalinks | Keywords: | |
Focuses: | administration | Cc: |
Description
Using a permalink structure of only /%postname%/
, it is not possible to create a post without a title which uses a slug without -2
.
In other words, because I choose to use only /%postname%/
, WordPress is forcing un-titled post slugs to default to the Post ID and appends -2
on every saved or published post that does not have a title as the auto-generated slug.
My only alternative, which I’m trying to avoid, is to manually create a slug for posts that do not have titles.
More discussion here: https://wordpress.org/support/topic/use-two-permalink-structures-at-the-same-time
Change History (2)
#1
@
7 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#2
@
7 years ago
Would you consider /%post_id%/
to be numeric slugs?
I tested changing permalinks with the setting above and it was exactly what I expected for the slugs, which was using the Post ID as the slug, going up in numeric order. It even worked perfectly, as I was expecting with posts without a title.
Permalinks perform a check for duplicate slugs and will append -2
if that exists, I understand that. But for WordPress installs that use the /&postname&/
setting, it seems reasonable that posts with no title could use the same structure that /%post_id%/
provides, which appears to be the Post ID in numeric order.
This is intentional, as WordPress does not support numeric slugs. Appending
-2
transforms the numeric post_id of123
into a string of123-2
.See #5305 for where that was introduced.
If you want titleless posts to have a different slug, you should be able to use the wp_unique_post_slug filter to change numeric-slugs to something else.
I'm marking this as
invalid
due to the behaviour being intentional, and WordPress's inability to support numeric slugs at present.