wp_unique_term_slug ( $slug, $term )

  • (string) slug The string that will be tried for a unique slug.
  • (object) term The term object that the `$slug` will belong to.
  • (string) Will return a true unique slug.
Defined at:


Makes term slug unique, if it isn't already.The `$slug` has to be unique global to every taxonomy, meaning that one taxonomy term can't have a matching slug with another taxonomy term. Each slug has to be globally unique for every taxonomy. The way this works is that if the taxonomy that the term belongs to is hierarchical and has a parent, it will append that parent to the $slug. If that still doesn't return a unique slug, then it tries to append a number until it finds a number that is truly unique. The only purpose for `$term` is for appending a parent, if one exists.

Related Functions

wp_unique_post_slug, wp_count_terms, wp_unique_id, wp_enqueue_style, wp_update_term_count

Top Google Results

User discussions

wpseek mobile