Whenever a new Custom Post is added through a plugin or code; usually WordPress permalinks need to be flushed.
- Step 1: In the WordPress admin area, go to “Settings > Permalinks“
- Step 2: Click “Save Changes“
- Step 3: Permalinks and rewrite rules are flushed.
By saving the permalink settings, WordPress regenerates the necessary rewrite rules and flushes the existing permalink cache. This ensures that any changes or updates you have made to your permalinks structure are applied correctly.
It’s important to note that refreshing or flushing permalinks might temporarily affect the accessibility of your site’s pages. However, this issue should resolve automatically once the permalinks are regenerated.
How to do this with WP CLI command?
To refresh or flush WordPress permalinks using the WP-CLI command-line tool, follow these steps:
Step 1: Open a command-line interface (CLI) or terminal.
Step 2: Navigate to the root directory of your WordPress installation using the 'cd
‘ command. For example:
cd /path/to/your/wordpress/installation
Remember to replace “/path/to/your/wordpress/installation
” with the actual path to your WordPress installation directory.
Step 3: Run the following WP-CLI command to flush the permalinks:
wp rewrite flush
Step 4: Press Enter to execute the command.
The wp rewrite flush
command regenerates the rewrite rules for your WordPress site, which includes refreshing the permalinks.
After running the command, you should see a success message indicating that the rewrite rules have been flushed.
Please note that using the wp rewrite flush
command can affect the accessibility of your site’s pages temporarily, similar to saving permalink changes in the WordPress admin area. However, the issue should resolve automatically once the permalinks are regenerated.