Enpoint Not Found in Rewrite Tag Permalink

Rewrite tags aren’t used in the context of add_rewrite_rule. If you were to use your tag in the post permalink settings under Settings > Permalinks, then your tag would be present in the link passed to the post_link filter. I think you need to add a new permalink structure containing the tag directly to the rewrite object to have a custom tag in there. As it stands, it’s redundant since you’re already adding query vars (which add_rewrite_tag also does). Also note that in your 2nd rule, the value of custom_category is in $matches[1]. For your page_link filter, you can use the 2nd argument passed to the filter, which is the page object, to check if that page has a custom_category and build the permalink you need in that case.

tech