How to Refresh / Flush WordPress Permalinks
Table of Contents
To flush WordPress rewrite rules or permalinks (usually needs to be done manually for new custom post types) from the admin Dashboard:
- Step 1: In the main admin menu find "Settings > Permalinks".
- Step 2: Scroll down if needed and click "Save Changes".
- Step 3: Rewrite rules and permalinks are flushed.
Flushing rewrite rules in PHP
To flush the permalinks or rewrite rules from your theme or plugin you need to use the
<?php flush_rewrite_rules(); ?>
If you are not familiar with PHP or writing custom code its best 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.
When To Flush WordPress Permalinks
WordPress permalinks should be flushed when one of the following takes place:
- You register a post type or taxonomy.
- You install a new plugin or theme.
- You add code that affects the WordPress rewrite rules.