WordPress как на ладони
Новые WordPress шаблоны Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru

wp rewrite

Перечисляет или сбрасывает правила перезаписи сайта, обновляет структуру ссылок.

See WP Rewrite class reference.

Список команд Описание
Сброс правил перезаписи.
Обновляет структуру постоянных ссылок.
Возвращает список текущих правил перезаписи.

Примеры

# 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

Исходный код команд


меню

wp rewrite flush

Сброс правил перезаписи.

wp rewrite flush [--hard]

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

Использование

wp rewrite flush [--hard]

Можно указать Глобальные параметры и следующие:

[--hard]
Perform a hard flush - update .htaccess rules as well as rewrite rules in database. Works only on single site installs.

Примеры

$ wp rewrite flush
Success: Rewrite rules flushed.

wp rewrite structure

Обновляет структуру постоянных ссылок.

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

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

Использование

wp rewrite structure {permastruct} [--category-base={base}] [--tag-base={base}] [--hard]

Можно указать Глобальные параметры и следующие:

{permastruct}
The new permalink structure to apply.
[--category-base={base}]
Set the base for category permalinks, i.e. '/category/'.
[--tag-base={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.

Примеры

$ wp rewrite structure '/%year%/%monthnum%/%postname%/'
Success: Rewrite structure set.
меню

wp rewrite list

Возвращает список текущих правил перезаписи.

wp rewrite list [--match=<url>] [--source=<source>] [--fields=<fields>] [--format=<format>]

Использование

wp rewrite list [--match={url}] [--source={source}] [--fields={fields}] [--format={format}]

Можно указать Глобальные параметры и следующие:

[--match={url}]
Show rewrite rules matching a particular URL.
[--source={source}]
Show rewrite rules from a particular source.
[--fields={fields}]
Limit the output to specific fields. Defaults to match,query,source.
[--format={format}]

Render output in a particular format.
По умолчанию: table
Может быть:

  • table
  • csv
  • json
  • count
  • yaml

Примеры

$ 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
Комментариев нет
    Здравствуйте, !     Войти . Зарегистрироваться