wp_get_term_taxonomy_parent_id

Returns the term's parent's term_ID.

Description

(int|false) wp_get_term_taxonomy_parent_id( (int) $term_id, (string) $taxonomy ); 

Returns (int|false)

False on error.

Parameters (2)

0. $term_id (int)
The term id.
1. $taxonomy (string)
Taxonomy name.

Usage

  1. if ( !function_exists( 'wp_get_term_taxonomy_parent_id' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // The term id. 
  5. $term_id = -1; 
  6.  
  7. // Taxonomy name. 
  8. $taxonomy = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_get_term_taxonomy_parent_id($term_id, $taxonomy); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) { 
  2. $term = get_term( $term_id, $taxonomy ); 
  3. if ( ! $term || is_wp_error( $term ) ) { 
  4. return false; 
  5. return (int) $term->parent;