wp rewrite

Lists or flushes the site’s rewrite rules, updates the permalink structure.

See the WordPress Rewrite API and WP Rewrite class reference.

Subcommands

CommandDescription
wp rewrite flushFlushes rewrite rules
wp rewrite listGets a list of the current rewrite rules
wp rewrite structureUpdates the permalink structure

Examples

bash
# Flush rewrite rules
$ wp rewrite flush
Success: Rewrite rules flushed.

# Update permalink structure
$ wp rewrite structure '/%year%/%monthnum%/%postname%'
Success: Rewrite structure set.

# List rewrite rules
$ wp rewrite list --format=csv
match,query,source
^wp-json/?$,index.php?rest_route=/,other
^wp-json/(.*)?,index.php?rest_route=/$matches[1],other
category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$,index.php?category_name=$matches[1]&feed=$matches[2],category