Summery Summery
Check if a term is an ancestor of another term.
Syntax Syntax
Description Description
You can use either an id or the term object for both parameters.
Parameters Parameters
- $term1
-
(Required) ID or object to check if this is the parent term.
- $term2
-
(Required) The child term.
- $taxonomy
-
(Required) Taxonomy name that $term1 and
$term2
belong to.
Return Return
(bool) Whether $term2
is a child of $term1
.
Source Source
File: wp-includes/taxonomy.php
$where = 't.slug = %s'; $else_where = 't.name = %s'; $where_fields = array( $slug ); $else_where_fields = array( $term ); $orderby = 'ORDER BY t.term_id ASC'; $limit = 'LIMIT 1'; if ( ! empty( $taxonomy ) ) { if ( is_numeric( $parent ) ) { $parent = (int) $parent; $where_fields[] = $parent; $else_where_fields[] = $parent; $where .= ' AND tt.parent = %d'; $else_where .= ' AND tt.parent = %d'; } $where_fields[] = $taxonomy; $else_where_fields[] = $taxonomy;
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |