This code works good:
$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.freuciv.com/'); echo "<a href='$link'>$name</a><br />"; } } It generates:
- Term1 (first level - parent)
- Term2 (second level - child)
I would like to get only the first level terms. How to modify it?
if ($term->parent) continue;at the top of the for loop.