wp rewrite structure

Updates the permalink structure.

Sets the post permalink structure to the specified pattern.

To regenerate a .htaccess file with WP-CLI, you’ll need to add the mod_rewrite module to your WP-CLI config:

yaml
apache_modules:
  - mod_rewrite

Synopsis

bash
wp rewrite structure <permastruct> [--category-base=<base>] [--tag-base=<base>] [--hard]

Options

The new permalink structure to apply.

[–category-base=] Set the base for category permalinks, i.e. ‘/category/’.

[–tag-base=] Set the base for tag permalinks, i.e. ‘/tag/’.

[–hard] Perform a hard flush – update .htaccess rules as well as rewrite rules in database.

Examples

bash
$ wp rewrite structure '/%year%/%monthnum%/%postname%/'
Success: Rewrite structure set.