wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_create_term › WordPress Function

Od2.8.0
Przestarzałyn/a
wp_create_term ( $tag_name, $taxonomy = 'post_tag' )
Parametry: (2)
  • (string) $tag_name The term name.
    Wymagane: Tak
  • (string) $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'.
    Wymagane: Nie
    Domyślny: 'post_tag'
Powrót:
  • (array|WP_Error)
Zdefiniowane na:
Codex:

Adds a new term to the database if it does not already exist.



Źródło

function wp_create_term( $tag_name, $taxonomy = 'post_tag' ) {
	$id = term_exists( $tag_name, $taxonomy );
	if ( $id ) {
		return $id;
	}

	return wp_insert_term( $tag_name, $taxonomy );
}