term_exists

SummerySummery

Determines whether a taxonomy term exists.

Syntax

term_exists( int|string $term, string $taxonomy = '', int $parent = null )

DescriptionDescription

Formerly is_term(), introduced in 2.3.0.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

ParametersParameters

$term

(int|string) (Required) The term to check. Accepts term ID, slug, or name.

$taxonomy

(string) (Optional) The taxonomy name to use.

Default value: ''

$parent

(int) (Optional) ID of parent term under which to confine the exists search.

Default value: null

ReturnReturn

(mixed) Returns null if the term does not exist. Returns the term ID if no taxonomy is specified and the term ID exists. Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists. Returns 0 if term ID 0 is passed to the function.

SourceSource

File: wp-includes/taxonomy.php


			

ChangelogChangelog

Changelog
Version Description
3.0.0 Introduced.
Scroll to Top