Is there a list of characters, that are not allowed / are allowed in Tags? Or are there some more complex rules?
I first ran into the issue, that some tags are ok with a *
-prefix, like: *BLA-BL-BLA
but others are not *BLA-BL-BLA blah
.
But after doing more testing, i found out, that i can not add a tag like +BLA-BL-BLA blah
after *BLA-BL-BLA blah
. The other way round also does not work.
It seems like the special chars get removed before a comparison and then the string matches an existing tag…
Basically, when you add a new term, WordPress will use term_exists()
to validate term before add it to database.
-
term_exists()
uses sanitize_title()
which uses remove_accents()
and sanitize_title_with_dashes()
to sanitize term.
-
remove_accents()
will converts all accent characters to ASCII characters and sanitize_title_with_dashes()
will limits the output to alphanumeric characters, underscore (_) and dash (-), whitespaces will be converted to dashes, uppercase characters will be converted to lowercase characters.
-
WordPress also doesn’t allow to create terms which have the same term slug at the same level of a taxonomy hierarchy.
So, every characters which don’t output the same term slug at the same level of a taxonomy hierarchy after passed through sanitize_title()
function are allowed characters.