Line 29 is where your error is. It just has an IF statement in the ID field, not anything like the_sub_field echoing an actual value. Another thing I’d keep in mind is if your ACF field is storing an anchor with a hash, the ID should be without the hash.