Query bug fix for custom post type