Just have a quick test and seems both methods working well.
// @Rup's method
$terms = get_the_terms(get_the_ID(), 'my_taxonomy');
if (!is_wp_error($terms) && !empty($terms)) {
foreach ($terms as $term) {
// skip if parent > 0
if( $term->parent )
continue;
$name = $term->name;
$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.freuciv.com/');
echo "<a href="https://wordpress.stackexchange.com/questions/366690/$link">$name</a><br />";
}
}
or
$terms = get_the_terms(get_the_ID(), 'my_taxonomy');
if (!is_wp_error($terms) && !empty($terms)) {
foreach ($terms as $term) {
// only do if parent is 0 (top most)
if( $term->parent == 0 ) {
$name = $term->name;
$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.freuciv.com/');
echo "<a href="https://wordpress.stackexchange.com/questions/366690/$link">$name</a><br />";
}
}
}