Flush Rewrite Rules

Remove rewrite rules and then recreate rewrite rules. This method can be used to refresh WordPress’ rewrite rule cache. Generally, this should be used after programmatically adding one or more custom rewrite rules.

When it is necessary?
-> Usually needs to flush rewrite rules for new custom post types.
-> You should only flush rules on activation or deactivation of a plugin or theme.
-> If you get 404 Page not found error on some pages/posts that already exist.

To flush WordPress rewrite rules or permalinks from the Dashboard:
1: In the main menu find Settings > Permalinks.
2: Scroll down if needed and click ‘Save Changes‘.
3: Rewrite rules and permalinks are flushed.