Opened 4 years ago

Last modified 17 months ago

#10792 new enhancement

ampersands and slashes stripped out of slugs

Reported by: alxndr Owned by:
Priority: low Milestone: Future Release
Component: Formatting Version:
Severity: trivial Keywords: has-patch needs-refresh
Cc:

Description

In slugs for taxonomies or post permalinks, slashes (/\) and ampersands (&) are stripped out. More useful URLs would be created by turning slashes into hyphens, and ampersands into the word "and".

e.g.:

"songs by Lennon/McCartney"
expected slug: "songs-by-lennon-mccartney"
actual slug: "songs-by-lennonmccartney"

"Us & Them"
expected slug: "us-and-them"
actual slug: "us-them"

Attachments (1)

slug-slash-ampersand.2.patch (594 bytes) - added by alxndr 4 years ago.
replaces slashes with hyphens in post title slugs and taxonomy term slugs; replaces ampersands with "and" and "&c" with "etc" in post title slugs

Download all attachments as: .zip

Change History (10)

alxndr4 years ago

replaces slashes with hyphens in post title slugs and taxonomy term slugs; replaces ampersands with "and" and "&c" with "etc" in post title slugs

This patch doesn't extend the ampersand fix to category/tag slugs (but the slash fix works). Perhaps ampersands are being stripped out before the title hits sanitize_title_with_dashes() ? I haven't dug around enough yet...

  • Milestone changed from Unassigned to Future Release

Agree with the slash replacement.

Don't agree with the & replacement due to internationalization problems: if you write a blog in french, you won't want '&' to be replaced with 'and'.

Oh right. ('and') perhaps?

Arg... that should have been

__('and')
  • Component changed from General to Formatting
  • Keywords has-patch added
  • Milestone changed from Future Release to 3.3

Related: #10823

  • Keywords needs-refresh added

We already have __(' and ') string in .pot from wp_sprintf_l(), so we probably can use it here.

  • Milestone changed from 3.3 to Future Release

How can I force to use the slash in the url? I want to use a slash in my post url, but when I save my custom slug in the post editor it gets stripped out. There should be

Version 0, edited 17 months ago by blogbuzz (next)
Note: See TracTickets for help on using tickets.