, 2 "" "" . .
$current_tax = wp_get_post_terms( $post->ID, 'portfolio-categories', array() );
$current_tax_id = $curcat[0]->term_id;
$digital = get_term_by( 'slug', 'digital', 'portfolio-categories', OBJECT );
$print = get_term_by( 'slug', 'print', 'portfolio-categories', OBJECT );
$sub_digital = get_term_children( $digital->term_id, 'portfolio-categories' );
$sub_print = get_term_children( $print->term_id, 'portfolio-categories' );
$parent_cat_id = in_array($current_tax_id, $sub_digital) ? $digital->term_id : $print->term_id;
Please note that I changed the code to my own working code. There may be small typos. Therefore, please check and do not blindly copy this.
source
share