"Note that I don't recommend hooking the add_custom_rewrite_rule into the init action as it will fire too frequently. This is just an example. A better place to apply the function would be on theme activation, plugin activate, perhaps the save_post action, etc. Depending on what you need to do, you may only need to fire it once or just a few times."

I found this recommendation here. In my WP installation I use a third part plugin that is hooking into the init action to change a custom post type slug. Is this a problem?

1 Answer 1


It really depends on your situation. Whenever you add a rewrite rule and flush the permalinks, it will stay there till the next change/flush of the permalink's settings.

If it's vital for your rules to exist, you can check if it exists on init, and then add it if it's not there. Take a look at this answer to get a glimpse of how to check if a rewrite rule exists.

If it's not really necessary for your rules to exist ( for example, you are just doing it for SEO purpose ), you can hook into another action that doesn't run each time a page loads, such as plugin activation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.