Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#43593 closed defect (bug) (invalid)

Permalink setting of /%postname%/ appends -2 to all posts without titles

Reported by: micasuh Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.5
Component: Permalinks Keywords:
Focuses: administration Cc:


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 @dd32
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This is intentional, as WordPress does not support numeric slugs. Appending -2 transforms the numeric post_id of 123 into a string of 123-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.

#2 @micasuh
4 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.

Note: See TracTickets for help on using tickets.