$countries
is not a number, but w WP_Query
instance, so you can’t compare it with a number…
This means that you should replace this:
if ($countries > 7) {
with:
if ( $countries->found_posts > 7 ) {
It will check if there are more than 8 countries that match your criteria. This way you can even change ‘-1’ to ‘8’ and limit the number of posts you’re displaying and this condition will still work.