Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_create_term ›

Da2.8.0
Deprecaton/a
wp_create_term ( $tag_name, $taxonomy = 'post_tag' )
Parametri: (2)
  • (int|string) $tag_name
    Richiesto:
  • (string) $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
    Richiesto: No
    Default: 'post_tag'
Ritorna:
  • (array|WP_Error)
Definito a:
Codex:

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