Is it possible to add default prefix to the slug of each newly added Tag. So that full slug, would be stored in database (no rewrites).
For example:
- Name: Tag1 -> Slug: prefix-tag1
- Name: Tag2 -> Slug: prefix-tag2
- …
Is it possible to add default prefix to the slug of each newly added Tag. So that full slug, would be stored in database (no rewrites).
For example:
You must be logged in to post a comment.
You can use the
created_term
or thecreated_{taxonomy}
hooks which are fired just after a taxonomy term is created (the second only if it matches the taxonomy).The following will only alter terms in the taxonomy ‘my-taxonomy’. (I believe for the default tags, taxonomy should be ‘post_tag’).
Note: From the Codex:
This shouldn’t be a problem if you use this function before any terms are created, because prefixing the same string to unique slugs preserves uniquness.