WordPress开发者和主题制作者的搜索引擎



sync_category_tag_slugs ›

Since3.0.0
已弃用n/a
sync_category_tag_slugs ( $term, $taxonomy )
参数: (2)
  • (WP_Term|array) $term The term.
    Required: Yes
  • (string) $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are the only taxonomies which are processed by this function; anything else will be returned untouched.
    Required: Yes
返回:
  • (WP_Term|array) Returns `$term`, after filtering the 'slug' field with `sanitize_title()` if `$taxonomy` is 'category' or 'post_tag'.
定义在:
文档:

Synchronizes category and post tag slugs when global terms are enabled.



源码

function sync_category_tag_slugs( $term, $taxonomy ) {
	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
		if ( is_object( $term ) ) {
			$term->slug = sanitize_title( $term->name );
		} else {
			$term['slug'] = sanitize_title( $term['name'] );
		}
	}
	return $term;
}