Hi Matt,
You can create a relationship between terms easy with this code
add_action( 'mb_relationships_init', function () {
MB_Relationships_API::register( [
'id' => 'term_to_term',
'from' => [
'object_type' => 'term',
'taxonomy' => 'category',
],
'to' => [
'object_type' => 'term',
'taxonomy' => 'product_cat',
],
] );
} );
an example between the category of post and product category of Product (WooCommerce). Then this code will show the terms which are related
$args = array(
'taxonomy' => 'product_cat',
'relationship' => [
'id' => 'term_to_term',
'from' => get_queried_object_id(), // You can pass object ID or full object
],
);
$terms = get_terms( $args );
foreach ( $terms as $term ) {
echo $term->name . '<br>';
}
To manipulate with the terms, please follow this documentation.