On this page
wp_get_term_taxonomy_parent_id( int $term_id, string $taxonomy ): int|false
Returns the term’s parent’s term ID.
Parameters
$term_idint Required-
Term ID.
$taxonomystring Required-
Taxonomy name.
Return
int|false Parent term ID on success, false on failure.
Source
File: wp-includes/taxonomy.php. View all references
function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
$term = get_term( $term_id, $taxonomy );
if ( ! $term || is_wp_error( $term ) ) {
return false;
}
return (int) $term->parent;
}
Related
Uses
| Uses | Description |
|---|---|
| get_term() wp-includes/taxonomy.php | Gets all term data from database by term ID. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_term_taxonomy_parent_id