Flushing Permalinks in WordPress

To flush WordPress rewrite rules or permalinks (usually needs to be done manually for new custom post types) from the Dashboard:

  • Step 1: In the main menu find "Settings > Permalinks".
  • Step 2: Scroll down if needed and click "Save Changes".
  • Step 3: Rewrite rules and permalinks are flushed.

Screenshot: Flushing the WordPress permalinks

Flushing rewrite rules in PHP

To flush the permalinks or rewrite rules from your theme or plugin you need to use the flush_rewrite_rules() function.

<?php flush_rewrite_rules(); ?>

If you are not familiar with PHP or writing custom code its best just to use the dashboard. This is because you should only flush rules on activation or deactivation of a plugin or theme.

If you flush the rules with any other hooks you can run into issues since you do not need or want to flush the rules that often.

Share this on