Class: WP_Term

Core class used to implement the WP_Term object.


Properties

Name Type(s) Default Value Summary
term_id integer Term ID.
name string The term's name.
slug string The term's slug.
term_group string The term's term_group.
term_taxonomy_id integer Term Taxonomy ID.
taxonomy string The term's taxonomy name.
description string The term's description.
parent integer ID of a term's parent term.
count integer Cached object count for this term.
filter string Stores the term object's sanitization level.

Does not correspond to a database field.

data object

Sanitized term data.


Methods

WP_Term:: __construct( WP_Term | object $term )

Constructor. Since 4.4.0.

Arguments

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

Term object.


WP_Term:: __get( string $key )

Getter. Since 4.4.0.

Arguments

Name Type(s) Default Value Description
$key string

Property to get.

Returns

mixed

Property value.


WP_Term:: filter( string $filter )

Sanitizes term fields, according to the filter type provided. Since 4.4.0.

Arguments

Name Type(s) Default Value Description
$filter string

Filter context. Accepts 'edit', 'db', 'display', 'attribute', 'js', 'raw'.


WP_Term:: get_instance( integer $term_id, string $taxonomy = null )

Retrieve WP_Term instance. Since 4.4.0.

Arguments

Name Type(s) Default Value Description
$term_id integer

Term ID.

$taxonomy string

Optional. Limit matched terms to those matching $taxonomy. Only used for disambiguating potentially shared terms.

Returns

WP_Term | WP_Error | false

Term object, if found. WP_Error if $term_id is shared between taxonomies and there's insufficient data to distinguish which term is intended. False for other failures.


WP_Term:: to_array( )

Converts an object to array. Since 4.4.0.

Returns

array

Object as array.


WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.