Fixed a problem where the JS was throwing an error on excluded post types

A bit messy but it works