Core Function
View Source on Trac ↗ get_term_by()
get_term_by(
mixed $field,
mixed $value,
mixed $taxonomy = '',
mixed $output = OBJECT,
mixed $filter = 'raw'
) Gets all term data from database by term field and data.
Parameters 3 required
| Name / Type | Description |
|---|---|
| $field string | Either 'slug', 'name', 'term_id' (or 'id', 'ID'), or 'term_taxonomy_id'. Required |
| (string | | int) $value Search for this term value. Required |
| $taxonomy string | Taxonomy name. Optional, if `$field` is 'term_taxonomy_id'. |
| string | $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Term object, an associative array, or a numeric array, respectively. Default OBJECT. Required |
| $filter string | Optional. How to sanitize term fields. Default 'raw'. |
Return Value
((WP_Term)
(WP_Term | array | false) WP_Term instance (or array) on success, depending on the `$output` value.
False if `$taxonomy` does not exist or `$term` was not found.
Function Information
Since Version
2.3.0
Source File
wp-includes/taxonomy.php
Advertisement