PHPackages                             wp-cli/widget-command - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. wp-cli/widget-command

ActiveWp-cli-package[CLI &amp; Console](/categories/cli)

wp-cli/widget-command
=====================

Adds, moves, and removes widgets; lists sidebars.

v2.2.2(1mo ago)67.2M↑20.1%113MITPHPCI passing

Since Apr 17Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/wp-cli/widget-command)[ Packagist](https://packagist.org/packages/wp-cli/widget-command)[ Docs](https://github.com/wp-cli/widget-command)[ RSS](/packages/wp-cli-widget-command/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (30)Used By (3)

wp-cli/widget-command
=====================

[](#wp-cliwidget-command)

Adds, moves, and removes widgets; lists sidebars.

[![Testing](https://github.com/wp-cli/widget-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/widget-command/actions/workflows/testing.yml) [![Code Coverage](https://camo.githubusercontent.com/d1fe6af25306da9a49a90a0d849f4ac47da5b572b0470dd59bab12148b0c5558/68747470733a2f2f636f6465636f762e696f2f67682f77702d636c692f7769646765742d636f6d6d616e642f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/wp-cli/widget-command/tree/main)

Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)

Using
-----

[](#using)

This package implements the following commands:

### wp widget

[](#wp-widget)

Manages widgets, including adding and moving them within sidebars.

```
wp widget

```

A [widget](https://developer.wordpress.org/themes/functionality/widgets/) adds content and features to a widget area (also called a [sidebar](https://developer.wordpress.org/themes/functionality/sidebars/)).

**EXAMPLES**

```
# 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 add

[](#wp-widget-add)

Adds a widget to a sidebar.

```
wp widget add   [] [--=]

```

Creates a new widget entry in the database, and associates it with the sidebar.

**OPTIONS**

```

	Widget name.

	ID for the corresponding sidebar.

[]
	Widget's current position within the sidebar. Defaults to last

[--=]
	Widget option to add, with its new value

```

**EXAMPLES**

```
# 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 deactivate

[](#wp-widget-deactivate)

Deactivates one or more widgets from an active sidebar.

```
wp widget deactivate ...

```

Moves widgets to Inactive Widgets.

**OPTIONS**

```
...
	Unique ID for the widget(s)

```

**EXAMPLES**

```
# Deactivate the recent-comments-2 widget.
$ wp widget deactivate recent-comments-2
Success: 1 widget deactivated.

```

### wp widget delete

[](#wp-widget-delete)

Deletes one or more widgets from a sidebar.

```
wp widget delete ...

```

**OPTIONS**

```
...
	Unique ID for the widget(s)

```

**EXAMPLES**

```
# Delete the recent-comments-2 widget from its sidebar.
$ wp widget delete recent-comments-2
Success: Deleted 1 of 1 widgets.

```

### wp widget list

[](#wp-widget-list)

Lists widgets associated with a sidebar.

```
wp widget list  [--fields=] [--format=]

```

**OPTIONS**

```

	ID for the corresponding sidebar.

[--fields=]
	Limit the output to specific object fields.

[--format=]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - csv
	  - ids
	  - json
	  - count
	  - yaml
	---

```

**AVAILABLE FIELDS**

These fields will be displayed by default for each widget:

- name
- id
- position
- options

There are no optionally available fields.

**EXAMPLES**

```
$ wp widget list sidebar-1 --fields=name,id --format=csv
name,id
meta,meta-5
search,search-3

```

### wp widget move

[](#wp-widget-move)

Moves the position of a widget.

```
wp widget move  [--position=] [--sidebar-id=]

```

Changes the order of a widget in its existing sidebar, or moves it to a new sidebar.

**OPTIONS**

```

	Unique ID for the widget

[--position=]
	Assign the widget to a new position.

[--sidebar-id=]
	Assign the widget to a new sidebar

```

**EXAMPLES**

```
# 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 patch

[](#wp-widget-patch)

Updates a nested value in a widget's options.

```
wp widget patch   ... [] [--format=]

```

**OPTIONS**

```

	Patch action to perform.
	---
	options:
	  - insert
	  - update
	  - delete
	---

	Unique ID for the widget.

...
	The name(s) of the keys within the value to locate the value to patch.

[]
	The new value. If omitted, the value is read from STDIN.

[--format=]
	The serialization format for the value.
	---
	default: plaintext
	options:
	  - plaintext
	  - json
	---

```

**EXAMPLES**

```
# Update a nested value in the options of the archives-1 widget
$ wp widget patch update archives-1 title "My Archives"
Success: Widget updated.

# Insert a new nested value into the options of the archives-1 widget
$ wp widget patch insert archives-1 new_key "New Value"
Success: Widget updated.

# Delete a nested value from the options of the archives-1 widget
$ wp widget patch delete archives-1 title
Success: Widget updated.

```

### wp widget reset

[](#wp-widget-reset)

Resets sidebar.

```
wp widget reset [...] [--all] [--inactive]

```

Removes all widgets from the sidebar and places them in Inactive Widgets.

**OPTIONS**

```
[...]
	One or more sidebars to reset.

[--all]
	If set, all sidebars will be reset.

[--inactive]
	If set, all inactive sidebars will also be reset, in addition to any sidebars specified via ... or selected with --all.

```

**EXAMPLES**

```
# Reset a sidebar
$ wp widget reset sidebar-1
Sidebar 'sidebar-1' reset.

# Reset multiple sidebars
$ wp widget reset sidebar-1 sidebar-2
Sidebar 'sidebar-1' reset.
Sidebar 'sidebar-2' reset.

# Reset all sidebars
$ wp widget reset --all
Sidebar 'sidebar-1' reset.
Sidebar 'sidebar-2' reset.
Sidebar 'sidebar-3' reset.

# Reset all inactive sidebars
$ wp widget reset --inactive
Sidebar 'old-sidebar-1' reset.

```

### wp widget update

[](#wp-widget-update)

Updates options for an existing widget.

```
wp widget update  [--=]

```

**OPTIONS**

```

	Unique ID for the widget

[--=]
	Field to update, with its new value

```

**EXAMPLES**

```
# Change calendar-1 widget title to "Our Calendar"
$ wp widget update calendar-1 --title="Our Calendar"
Success: Widget updated.

```

### wp sidebar

[](#wp-sidebar)

Lists registered sidebars.

```
wp sidebar

```

A [sidebar](https://developer.wordpress.org/themes/functionality/sidebars/) is any widgetized area of your theme.

**EXAMPLES**

```
# List sidebars
$ wp sidebar list --fields=name,id --format=csv
name,id
"Widget Area",sidebar-1
"Inactive Widgets",wp_inactive_widgets

```

### wp sidebar exists

[](#wp-sidebar-exists)

Check if a sidebar exists.

```
wp sidebar exists

```

**OPTIONS**

```

	The sidebar ID.

```

**EXAMPLES**

```
$ wp sidebar exists sidebar-1
$ wp sidebar exists wp_inactive_widgets && echo "exists"

```

### wp sidebar get

[](#wp-sidebar-get)

Get details about a specific sidebar.

```
wp sidebar get  [--fields=] [--format=]

```

**OPTIONS**

```

	The sidebar ID.

[--fields=]
	Limit the output to specific object fields.

[--format=]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - csv
	  - json
	  - ids
	  - count
	  - yaml
	---

```

**EXAMPLES**

```
$ wp sidebar get sidebar-1
$ wp sidebar get wp_inactive_widgets --format=json

```

### wp sidebar list

[](#wp-sidebar-list)

Lists registered sidebars.

```
wp sidebar list [--inactive] [--fields=] [--format=]

```

**OPTIONS**

```
[--inactive]
	If set, only inactive sidebars will be listed.

[--fields=]
	Limit the output to specific object fields.

[--format=]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - csv
	  - json
	  - ids
	  - count
	  - yaml
	---

```

**AVAILABLE FIELDS**

These fields will be displayed by default for each sidebar:

- name
- id
- description

These fields are optionally available:

- class
- before\_widget
- after\_widget
- before\_title
- after\_title

**EXAMPLES**

```
$ wp sidebar list --fields=name,id --format=csv
name,id
"Widget Area",sidebar-1
"Inactive Widgets",wp_inactive_widgets

$ wp sidebar list --inactive --fields=id --format=csv
id
old-sidebar-1

```

Installing
----------

[](#installing)

This package is included with WP-CLI itself, no additional installation necessary.

To install the latest version of this package over what's included in WP-CLI, run:

```
wp package install git@github.com:wp-cli/widget-command.git

```

Contributing
------------

[](#contributing)

We appreciate you taking the initiative to contribute to this project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

For a more thorough introduction, [check out WP-CLI's guide to contributing](https://make.wordpress.org/cli/handbook/contributing/). This package follows those policy and guidelines.

### Reporting a bug

[](#reporting-a-bug)

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should [search existing issues](https://github.com/wp-cli/widget-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/widget-command/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).

### Creating a pull request

[](#creating-a-pull-request)

Want to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/widget-command/issues/new) to discuss whether the feature is a good fit for the project.

Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.

### License

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

GitHub issues aren't for general support questions, but there are other venues you can try:

*This README.md is generated dynamically from the project's codebase using `wp scaffold package-readme` ([doc](https://github.com/wp-cli/scaffold-package-command#wp-scaffold-package-readme)). To suggest changes, please submit a pull request against the corresponding part of the codebase.*

###  Health Score

65

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity52

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 55.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~130 days

Total

26

Last Release

54d ago

Major Versions

v1.0.5 → v2.0.02018-08-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b5740d002b5556abcceed36e016c8f8ba6f533eefef6107b3c60a830704993b?d=identicon)[danielbachhuber](/maintainers/danielbachhuber)

![](https://www.gravatar.com/avatar/6dde7f578e5530884238e7173f768ae3a890b6d66eb99262a82f2c494a1b67d4?d=identicon)[schlessera](/maintainers/schlessera)

---

Top Contributors

[![danielbachhuber](https://avatars.githubusercontent.com/u/36432?v=4)](https://github.com/danielbachhuber "danielbachhuber (547 commits)")[![scribu](https://avatars.githubusercontent.com/u/225715?v=4)](https://github.com/scribu "scribu (150 commits)")[![schlessera](https://avatars.githubusercontent.com/u/83631?v=4)](https://github.com/schlessera "schlessera (130 commits)")[![swissspidy](https://avatars.githubusercontent.com/u/841956?v=4)](https://github.com/swissspidy "swissspidy (35 commits)")[![ernilambar](https://avatars.githubusercontent.com/u/2098823?v=4)](https://github.com/ernilambar "ernilambar (30 commits)")[![iamsohilvahora](https://avatars.githubusercontent.com/u/41704714?v=4)](https://github.com/iamsohilvahora "iamsohilvahora (12 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (8 commits)")[![NateWr](https://avatars.githubusercontent.com/u/2306629?v=4)](https://github.com/NateWr "NateWr (8 commits)")[![miya0001](https://avatars.githubusercontent.com/u/309946?v=4)](https://github.com/miya0001 "miya0001 (7 commits)")[![mwilliamson](https://avatars.githubusercontent.com/u/391876?v=4)](https://github.com/mwilliamson "mwilliamson (6 commits)")[![nyordanov](https://avatars.githubusercontent.com/u/192220?v=4)](https://github.com/nyordanov "nyordanov (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![mpeshev](https://avatars.githubusercontent.com/u/328189?v=4)](https://github.com/mpeshev "mpeshev (4 commits)")[![francescolaffi](https://avatars.githubusercontent.com/u/357331?v=4)](https://github.com/francescolaffi "francescolaffi (4 commits)")[![wojsmol](https://avatars.githubusercontent.com/u/4176111?v=4)](https://github.com/wojsmol "wojsmol (3 commits)")[![clemens-tolboom](https://avatars.githubusercontent.com/u/371014?v=4)](https://github.com/clemens-tolboom "clemens-tolboom (3 commits)")[![gitlost](https://avatars.githubusercontent.com/u/481982?v=4)](https://github.com/gitlost "gitlost (3 commits)")[![johnbillion](https://avatars.githubusercontent.com/u/208434?v=4)](https://github.com/johnbillion "johnbillion (3 commits)")[![lkwdwrd](https://avatars.githubusercontent.com/u/1895738?v=4)](https://github.com/lkwdwrd "lkwdwrd (3 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (3 commits)")

---

Tags

clihacktoberfestwidgetwidgetswordpresswp-cliwp-cli-package

### Embed Badge

![Health badge](/badges/wp-cli-widget-command/health.svg)

```
[![Health](https://phpackages.com/badges/wp-cli-widget-command/health.svg)](https://phpackages.com/packages/wp-cli-widget-command)
```

###  Alternatives

[wp-cli/entity-command

Manage WordPress comments, menus, options, posts, sites, terms, and users.

1048.8M55](/packages/wp-cli-entity-command)[wp-cli/scaffold-command

Generates code for post types, taxonomies, blocks, plugins, child themes, etc.

1717.7M15](/packages/wp-cli-scaffold-command)[wp-cli/i18n-command

Provides internationalization tools for WordPress projects.

11610.4M52](/packages/wp-cli-i18n-command)[wp-cli/extension-command

Manages plugins and themes, including installs, activations, and updates.

919.0M53](/packages/wp-cli-extension-command)[wp-cli/db-command

Performs basic database operations using credentials stored in wp-config.php.

768.0M30](/packages/wp-cli-db-command)[wp-cli/server-command

Launches PHP's built-in web server for a specific WordPress installation.

687.2M5](/packages/wp-cli-server-command)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
