Function: sanitize_term

sanitize_term( array | object $term, string $taxonomy, string $context )

Sanitize Term all fields.

Shortcut: st

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

Relies on sanitize_term_field() to sanitize the term. The difference is that this function will sanitize all fields. The context is based on sanitize_term_field().

The $term is expected to be either an array or an object.

Parameters

Name Type(s) Default Value Description
$term array | object

The term to check.

$taxonomy string

The taxonomy name to use.

$context string 'display'

Optional. Context in which to sanitize the term. Accepts 'edit', 'db', 'display', 'attribute', or 'js'. Default 'display'.

Returns

array | object

Term with all fields sanitized.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.