Add_rewrite_rule doesn’t add custom url in plugin

You need to call custom_urls_rules() directly in your activation function to add the rules. The init action doesn’t happen in the context of plugin activation, so the rules never get added before the flush.

The other filter and action also don’t need to happen on activation, they just need to be hooked on all subsequent requests.

Leave a Comment