Custom Taxonomy URL are redirecting to page with the same name

I found a solution to this by some extensive googling. The key is to declare the taxanomy before the ctp. I have no idea why, but it works =)

source: https://cnpagency.com/blog/the-right-way-to-do-wordpress-custom-taxonomy-rewrites/

error code: 523