Checking the count within a foreach loop
You can achieve this very easily, just count the array with the terms. Also if I could suggest something more, I’d check for WP_Error a bit earlier, outside the foreach loop, instead of checking every single term, especially that you’re not using the $term_link variable anywhere. Just checking if get_the_terms() returns an array should be … Read more