Undefined property: WP_Post_Type::$ID
Try changing the get_queried_object()->ID to get_queried_object_id(). All the get queried object may not have a property name $ID. So this get_queried_object_id gives the $queried_object_id property value, which gets set on instantiation of WP_Query class. If the $queried_object_id isn’t set then it’ll give you 0.