wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_create_term › WordPress Function

Da2.8.0
Deprecaton/a
wp_create_term ( $tag_name, $taxonomy = 'post_tag' )
Parametri: (2)
  • (string) $tag_name The term name.
    Richiesto:
  • (string) $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'.
    Richiesto: No
    Default: 'post_tag'
Ritorna:
  • (array|WP_Error)
Definito a:
Codex:

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



Sorgenti

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 );
}