has_post_thumbnail() not working

Assuming that you’re in The Loop, you can fix this problem, by replacing:

with