get_term_field

SummerySummery

Get sanitized Term field.

Syntax

get_term_field( string $field, int|WP_Term $term, string $taxonomy = '', string $context = 'display' )

DescriptionDescription

The function is for contextual reasons and for simplicity of usage.

ParametersParameters

$field

(string) (Required) Term field to fetch.

$term

(int|WP_Term) (Required) Term ID or object.

$taxonomy

(string) (Optional) Taxonomy Name.

Default value: ''

$context

(string) (Optional) default is display. Look at sanitize_term_field() for available options.

Default value: 'display'

ReturnReturn

(string|int|null|WP_Error) Will return an empty string if $term is not an object or if $field is not set in $term.

SourceSource

File: wp-includes/taxonomy.php


			

ChangelogChangelog

Changelog
Version Description
4.4.0 The $taxonomy parameter was made optional. $term can also now accept a WP_Term object.
2.3.0 Introduced.

See alsoSee also

Scroll to Top