PHP Class Rewrite_Command, wp-cli

## EXAMPLES # 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 category/(.+?)/(feed|rdf|rss|rss2|atom)/?$,index.php?category_name=$matches[1]&feed=$matches[2],category category/(.+?)/embed/?$,index.php?category_name=$matches[1]&embed=true,category
Inheritance: extends WP_CLI_Command
Show file Open project: wp-cli/wp-cli

Public Methods

Method Description
apache_get_modules ( )
flush ( $args, $assoc_args ) Flush rewrite rules.
list_ ( $args, $assoc_args ) Get a list of the current rewrite rules.
structure ( $args, $assoc_args ) Update the permalink structure.

Private Methods

Method Description
apache_modules ( ) Expose apache modules if present in config

Method Details

apache_get_modules() public method

public apache_get_modules ( )

flush() public method

Resets WordPress' rewrite rules based on registered post types, etc. To regenerate a .htaccess file with WP-CLI, you'll need to add the mod_rewrite module to your wp-cli.yml or config.yml. For example: apache_modules: - mod_rewrite ## OPTIONS [--hard] : Perform a hard flush - update .htaccess rules as well as rewrite rules in database. Works only on single site installs. ## EXAMPLES $ wp rewrite flush Success: Rewrite rules flushed.
public flush ( $args, $assoc_args )

list_() public method

## OPTIONS [--match=] : Show rewrite rules matching a particular URL. [--source=] : Show rewrite rules from a particular source. [--fields=] : Limit the output to specific fields. Defaults to match,query,source. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - count - yaml --- ## EXAMPLES $ 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 category/(.+?)/(feed|rdf|rss|rss2|atom)/?$,index.php?category_name=$matches[1]&feed=$matches[2],category category/(.+?)/embed/?$,index.php?category_name=$matches[1]&embed=true,category
public list_ ( $args, $assoc_args )

structure() public method

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. For example: apache_modules: - mod_rewrite ## 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 $ wp rewrite structure '/%year%/%monthnum%/%postname%' Success: Rewrite structure set.
public structure ( $args, $assoc_args )