How to automatically flush permalinks in Wordpress

AuthorJez R. Emery
Date
31. August 2021
Time1 min read

Flushing permalinks when you enable a plugin is REALLY simple, it can be done with the following snippet. This snippet needs to be in the root file of your plugin, e.g. wp-content/plugins/plugin/plugin.php

  function pluginActivated()
  {
      flush_rewrite_rules();
  }
  register_activation_hook(__FILE__, 'pluginActivated');