I have two functions displaying a term list of the selected taxonomy:
First function:
$terms = get_the_terms(get_the_ID(), 'MY_TAXONOMY');
if (!is_wp_error($terms) && !empty($terms)) {
foreach ($terms AS $term) {
$name = $term->name;
$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.MYWEBSITE.com/');
echo "<a href='$link'>$name</a><br />";
}
}
Second function:
global $post;
$taxonomy = 'MY_TAXONOMY';
$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
if( $terms ) {
echo '<?ul>';
$terms = trim( implode( ',', (array) $terms ), ' ,' );
wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms );
echo '<?/ul>';
}
The first one ignores the hierarchy, but transforms the links as I need, i.e. so that they lead to queries of the WP's Facet Plugin. I understand that this line is key here:
$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.MYWEBSITE.com/');
The second one includes the hierarchy, but the links don't lead where I would like. How do I make this second function transform links like the first one?