wp widget
Управляет виджетами, включая их добавление и перемещение в боковых панелях.
Виджет добавляет контент и функционал в область виджета (в сайдбар).
| Список команд | Описание |
|---|---|
| wp widget list | Отображает список виджетов, связанных с боковой панелью. |
| wp widget add | Добавляет виджет в сайдбар. |
| wp widget update | Обновляет параметры существующего виджета. |
| wp widget move | Изменяет положение виджета. |
| wp widget deactivate | Деактивирует один или несколько виджетов из активной боковой панели. |
| wp widget delete | Удаляет один или несколько виджетов из боковой панели. |
| wp widget reset | Сбрасывает сайдбар. |
Примеры
# List widgets on a given sidebar
$ wp widget list sidebar-1
+----------+------------+----------+----------------------+
| name | id | position | options |
+----------+------------+----------+----------------------+
| meta | meta-6 | 1 | {"title":"Meta"} |
| calendar | calendar-2 | 2 | {"title":"Calendar"} |
+----------+------------+----------+----------------------+
# Add a calendar widget to the second position on the sidebar
$ wp widget add calendar sidebar-1 2
Success: Added widget to sidebar.
# Update option(s) associated with a given widget
$ wp widget update calendar-1 --title="Calendar"
Success: Widget updated.
# Delete one or more widgets entirely
$ wp widget delete calendar-2 archive-1
Success: 2 widgets removed from sidebar.
Исходный код команд
wp widget list
Отображает список виджетов, связанных с боковой панелью.
Использование
wp widget list {sidebar-id} [--fields={fields}] [--format={format}]
Можно указать Глобальные параметры и следующие:
{sidebar-id}- ID for the corresponding sidebar.
[--fields={fields}]- Limit the output to specific object fields.
[--format={format}]Render output in a particular format.
По умолчанию: table
Может быть:- table
- csv
- ids
- json
- count
- yaml
Доступные поля
These fields will be displayed by default for each widget:
- name
- id
- position
- options
There are no optionally available fields.
Примеры
$ wp widget list sidebar-1 --fields=name,id --format=csv name,id meta,meta-5 search,search-3
wp widget add
Добавляет виджет в сайдбар.
Creates a new widget entry in the database, and associates it with the sidebar.
Использование
wp widget add {name} {sidebar-id} [{position}] [--{field}={value}]
Можно указать Глобальные параметры и следующие:
{name}- Widget name.
{sidebar-id}- ID for the corresponding sidebar.
[{position}]- Widget's current position within the sidebar. Defaults to last
[--{field}={value}]- Widget option to add, with its new value
Примеры
# Add a new calendar widget to sidebar-1 with title "Calendar" $ wp widget add calendar sidebar-1 2 --title="Calendar" Success: Added widget to sidebar.
wp widget update
Обновляет параметры существующего виджета.
Использование
wp widget update {widget-id} [--{field}={value}]
Можно указать Глобальные параметры и следующие:
{widget-id}- Unique ID for the widget
[--{field}={value}]- Field to update, with its new value
Примеры
# Change calendar-1 widget title to "Our Calendar" $ wp widget update calendar-1 --title="Our Calendar" Success: Widget updated.
wp widget move
Изменяет положение виджета.
Changes the order of a widget in its existing sidebar, or moves it to a new sidebar.
Использование
wp widget move {widget-id} [--position={position}] [--sidebar-id={sidebar-id}]
Можно указать Глобальные параметры и следующие:
{widget-id}- Unique ID for the widget
[--position={position}]- Assign the widget to a new position.
[--sidebar-id={sidebar-id}]- Assign the widget to a new sidebar
Примеры
# Change position of widget $ wp widget move recent-comments-2 --position=2 Success: Widget moved.
# Move widget to Inactive Widgets $ wp widget move recent-comments-2 --sidebar-id=wp_inactive_widgets Success: Widget moved.
wp widget deactivate
Деактивирует один или несколько виджетов из активной боковой панели.
Moves widgets to Inactive Widgets.
Использование
wp widget deactivate {widget-id}...
Можно указать Глобальные параметры и следующие:
{widget-id}...- Unique ID for the widget(s)
Примеры
# Deactivate the recent-comments-2 widget. $ wp widget deactivate recent-comments-2 Success: 1 widget deactivated.
wp widget delete
Удаляет один или несколько виджетов из боковой панели.
Использование
wp widget delete {widget-id}...
Можно указать Глобальные параметры и следующие:
{widget-id}...- Unique ID for the widget(s)
Примеры
# Delete the recent-comments-2 widget from its sidebar. $ wp widget delete recent-comments-2 Success: Deleted 1 of 1 widgets.
wp widget reset
Сбрасывает сайдбар.
Removes all widgets from the sidebar and places them in Inactive Widgets.
Использование
wp widget reset [{sidebar-id}...] [--all]
Можно указать Глобальные параметры и следующие:
[{sidebar-id}...]- One or more sidebars to reset.
[--all]- If set, all sidebars will be reset.
Примеры
# Reset a sidebar $ wp widget reset sidebar-1 Success: Sidebar 'sidebar-1' reset.
# Reset multiple sidebars $ wp widget reset sidebar-1 sidebar-2 Success: Sidebar 'sidebar-1' reset. Success: Sidebar 'sidebar-2' reset.
# Reset all sidebars $ wp widget reset --all Success: Sidebar 'sidebar-1' reset. Success: Sidebar 'sidebar-2' reset. Success: Sidebar 'sidebar-3' reset.