How can I get the ID of parent’s taxonomy in WordPress?

I need to get the parent’s taxonomy ID by the sub taxonomy’s name.

E.g.:

Read More
Italy   - parent
Livingo - sub

On the Livingo page, I need to be able to get Italy‘s ID.

Related posts

Leave a Reply

1 comment

  1. $subCategory = get_term_by( 'slug', get_query_var( 'term' ), $current_taxonomy );
    $mainCategory = get_term_by( 'id', $subCategory->parent, $current_taxonomy );
    

    After that, $mainCategory will be an array with all details about that term (slug, name, parent etc).