Optional taxonomy in cpt permalink
You’re correct that the issue is caused by the fact that the rewrite rule is set to include the %tax-name% placeholder even when a taxonomy is not set for the post. One way to dynamically set the rewrite rule based on whether a taxonomy is set or not is to use the post_type_link filter. This … Read more