How to check if a post belongs to custom taxonomy – WordPress

I was trying to figure this issue out, when I realized that there isn’t currently a core function to check whether a post belongs to a taxonomy term.
This can be easily done using this function (copy and pasteinto your functions.php file)

Then call the function like this