Skip to content

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

License

Notifications You must be signed in to change notification settings

wp-cli/entity-command

Repository files navigation

wp-cli/entity-command

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

Testing

Quick links: Using | Installing | Contributing | Support

Using

This package implements the following commands:

wp comment

Creates, updates, deletes, and moderates comments.

wp comment

EXAMPLES

# Create a new comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.

# Update an existing comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.

# Delete an existing comment.
$ wp comment delete 1337 --force
Success: Deleted comment 1337.

# Trash all spam comments.
$ wp comment delete $(wp comment list --status=spam --format=ids)
Success: Trashed comment 264.
Success: Trashed comment 262.

wp comment approve

Approves a comment.

wp comment approve <id>...

OPTIONS

<id>...
	The IDs of the comments to approve.

EXAMPLES

# Approve comment.
$ wp comment approve 1337
Success: Approved comment 1337.

wp comment count

Counts comments, on whole blog or on a given post.

wp comment count [<post-id>]

OPTIONS

[<post-id>]
	The ID of the post to count comments in.

EXAMPLES

# Count comments on whole blog.
$ wp comment count
approved:        33
spam:            3
trash:           1
post-trashed:    0
all:             34
moderated:       1
total_comments:  37

# Count comments in a post.
$ wp comment count 42
approved:        19
spam:            0
trash:           0
post-trashed:    0
all:             19
moderated:       0
total_comments:  19

wp comment create

Creates a new comment.

wp comment create [--<field>=<value>] [--porcelain]

OPTIONS

[--<field>=<value>]
	Associative args for the new comment. See wp_insert_comment().

[--porcelain]
	Output just the new comment id.

EXAMPLES

# Create comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.

wp comment delete

Deletes a comment.

wp comment delete <id>... [--force]

OPTIONS

<id>...
	One or more IDs of comments to delete.

[--force]
	Skip the trash bin.

EXAMPLES

# Delete comment.
$ wp comment delete 1337 --force
Success: Deleted comment 1337.

# Delete multiple comments.
$ wp comment delete 1337 2341 --force
Success: Deleted comment 1337.
Success: Deleted comment 2341.

wp comment exists

Verifies whether a comment exists.

wp comment exists <id>

Displays a success message if the comment does exist.

OPTIONS

<id>
	The ID of the comment to check.

EXAMPLES

# Check whether comment exists.
$ wp comment exists 1337
Success: Comment with ID 1337 exists.

wp comment generate

Generates some number of new dummy comments.

wp comment generate [--count=<number>] [--post_id=<post-id>] [--format=<format>]

Creates a specified number of new comments with dummy data.

OPTIONS

[--count=<number>]
	How many comments to generate?
	---
	default: 100
	---

[--post_id=<post-id>]
	Assign comments to a specific post.

[--format=<format>]
	Render output in a particular format.
	---
	default: progress
	options:
	  - progress
	  - ids
	---

EXAMPLES

# Generate comments for the given post.
$ wp comment generate --format=ids --count=3 --post_id=123
138 139 140

# Add meta to every generated comment.
$ wp comment generate --format=ids --count=3 | xargs -d ' ' -I % wp comment meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.

wp comment get

Gets the data of a single comment.

wp comment get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]

OPTIONS

<id>
	The comment to get.

[--field=<field>]
	Instead of returning the whole comment, returns the value of a single field.

[--fields=<fields>]
	Limit the output to specific fields. Defaults to all fields.

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

EXAMPLES

# Get comment.
$ wp comment get 21 --field=content
Thanks for all the comments, everyone!

wp comment list

Gets a list of comments.

wp comment list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]

Display comments based on all arguments supported by WP_Comment_Query().

OPTIONS

[--<field>=<value>]
	One or more args to pass to WP_Comment_Query.

[--field=<field>]
	Prints the value of a single field for each comment.

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

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

AVAILABLE FIELDS

These fields will be displayed by default for each comment:

  • comment_ID
  • comment_post_ID
  • comment_date
  • comment_approved
  • comment_author
  • comment_author_email

These fields are optionally available:

  • comment_author_url
  • comment_author_IP
  • comment_date_gmt
  • comment_content
  • comment_karma
  • comment_agent
  • comment_type
  • comment_parent
  • user_id
  • url

EXAMPLES

# List comment IDs.
$ wp comment list --field=ID
22
23
24

# List comments of a post.
$ wp comment list --post_id=1 --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
+------------+---------------------+----------------+

# List approved comments.
$ wp comment list --number=3 --status=approve --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
| 30         | 2013-03-14 12:35:07 | John Doe       |
| 29         | 2013-03-14 11:56:08 | Jane Doe       |
+------------+---------------------+----------------+

# List unapproved comments.
$ wp comment list --number=3 --status=hold --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 8          | 2023-11-10 13:13:06 | John Doe       |
| 7          | 2023-11-10 13:09:55 | Mr WordPress   |
| 9          | 2023-11-10 11:22:31 | Jane Doe       |
+------------+---------------------+----------------+

# List comments marked as spam.
$ wp comment list --status=spam --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 2          | 2023-11-10 11:22:31 | Jane Doe       |
+------------+---------------------+----------------+

# List comments in trash.
$ wp comment list --status=trash --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 3          | 2023-11-10 11:22:31 | John Doe       |
+------------+---------------------+----------------+

wp comment meta

Adds, updates, deletes, and lists comment custom fields.

wp comment meta

EXAMPLES

# Set comment meta
$ wp comment meta set 123 description "Mary is a WordPress developer."
Success: Updated custom field 'description'.

# Get comment meta
$ wp comment meta get 123 description
Mary is a WordPress developer.

# Update comment meta
$ wp comment meta update 123 description "Mary is an awesome WordPress developer."
Success: Updated custom field 'description'.

# Delete comment meta
$ wp comment meta delete 123 description
Success: Deleted custom field.

wp comment meta add

Add a meta field.

wp comment meta add <id> <key> [<value>] [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to create.

[<value>]
	The value of the meta field. If omitted, the value is read from STDIN.

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

wp comment meta delete

Delete a meta field.

wp comment meta delete <id> [<key>] [<value>] [--all]

OPTIONS

<id>
	The ID of the object.

[<key>]
	The name of the meta field to delete.

[<value>]
	The value to delete. If omitted, all rows with key will deleted.

[--all]
	Delete all meta for the object.

wp comment meta get

Get meta field value.

wp comment meta get <id> <key> [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to get.

[--format=<format>]
	Get value in a particular format.
	---
	default: var_export
	options:
	  - var_export
	  - json
	  - yaml
	---

wp comment meta list

List all metadata associated with an object.

wp comment meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]

OPTIONS

<id>
	ID for the object.

[--keys=<keys>]
	Limit output to metadata of specific keys.

[--fields=<fields>]
	Limit the output to specific row fields. Defaults to id,meta_key,meta_value.

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

[--orderby=<fields>]
	Set orderby which field.
	---
	default: id
	options:
	 - id
	 - meta_key
	 - meta_value
	---

[--order=<order>]
	Set ascending or descending order.
	---
	default: asc
	options:
	 - asc
	 - desc
	---

[--unserialize]
	Unserialize meta_value output.

wp comment meta patch

Update a nested value for a meta field.

wp comment meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

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

<id>
	The ID of the object.

<key>
	The name of the meta field to update.

<key-path>...
	The name(s) of the keys within the value to locate the value to patch.

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

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

wp comment meta pluck

Get a nested value from a meta field.

wp comment meta pluck <id> <key> <key-path>... [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to get.

<key-path>...
	The name(s) of the keys within the value to locate the value to pluck.

[--format=<format>]
	The output format of the value.
	---
	default: plaintext
	options:
	  - plaintext
	  - json
	  - yaml

wp comment meta update

Update a meta field.

wp comment meta update <id> <key> [<value>] [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to update.

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

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

wp comment recount

Recalculates the comment_count value for one or more posts.

wp comment recount <id>...

OPTIONS

<id>...
	IDs for one or more posts to update.

EXAMPLES

# Recount comment for the post.
$ wp comment recount 123
Updated post 123 comment count to 67.

wp comment spam

Marks a comment as spam.

wp comment spam <id>...

OPTIONS

<id>...
	The IDs of the comments to mark as spam.

EXAMPLES

# Spam comment.
$ wp comment spam 1337
Success: Marked as spam comment 1337.

wp comment status

Gets the status of a comment.

wp comment status <id>

OPTIONS

<id>
	The ID of the comment to check.

EXAMPLES

# Get status of comment.
$ wp comment status 1337
approved

wp comment trash

Trashes a comment.

wp comment trash <id>...

OPTIONS

<id>...
	The IDs of the comments to trash.

EXAMPLES

# Trash comment.
$ wp comment trash 1337
Success: Trashed comment 1337.

wp comment unapprove

Unapproves a comment.

wp comment unapprove <id>...

OPTIONS

<id>...
	The IDs of the comments to unapprove.

EXAMPLES

# Unapprove comment.
$ wp comment unapprove 1337
Success: Unapproved comment 1337.

wp comment unspam

Unmarks a comment as spam.

wp comment unspam <id>...

OPTIONS

<id>...
	The IDs of the comments to unmark as spam.

EXAMPLES

# Unspam comment.
$ wp comment unspam 1337
Success: Unspammed comment 1337.

wp comment untrash

Untrashes a comment.

wp comment untrash <id>...

OPTIONS

<id>...
	The IDs of the comments to untrash.

EXAMPLES

# Untrash comment.
$ wp comment untrash 1337
Success: Untrashed comment 1337.

wp comment update

Updates one or more comments.

wp comment update <id>... --<field>=<value>

OPTIONS

<id>...
	One or more IDs of comments to update.

--<field>=<value>
	One or more fields to update. See wp_update_comment().

EXAMPLES

# Update comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.

wp menu

Lists, creates, assigns, and deletes the active theme's navigation menus.

wp menu

See the Navigation Menus reference in the Theme Handbook.

EXAMPLES

# Create a new menu
$ wp menu create "My Menu"
Success: Created menu 200.

# List existing menus
$ wp menu list
+---------+----------+----------+-----------+-------+
| term_id | name     | slug     | locations | count |
+---------+----------+----------+-----------+-------+
| 200     | My Menu  | my-menu  |           | 0     |
| 177     | Top Menu | top-menu | primary   | 7     |
+---------+----------+----------+-----------+-------+

# Create a new menu link item
$ wp menu item add-custom my-menu Apple http://apple.com --porcelain
1922

# Assign the 'my-menu' menu to the 'primary' location
$ wp menu location assign my-menu primary
Success: Assigned location primary to menu my-menu.

wp menu create

Creates a new menu.

wp menu create <menu-name> [--porcelain]

OPTIONS

<menu-name>
	A descriptive name for the menu.

[--porcelain]
	Output just the new menu id.

EXAMPLES

$ wp menu create "My Menu"
Success: Created menu 200.

wp menu delete

Deletes one or more menus.

wp menu delete <menu>...

OPTIONS

<menu>...
	The name, slug, or term ID for the menu(s).

EXAMPLES

$ wp menu delete "My Menu"
Deleted menu 'My Menu'.
Success: Deleted 1 of 1 menus.

wp menu item

List, add, and delete items associated with a menu.

wp menu item

EXAMPLES

# Add an existing post to an existing menu
$ wp menu item add-post sidebar-menu 33 --title="Custom Test Post"
Success: Menu item added.

# Create a new menu link item
$ wp menu item add-custom sidebar-menu Apple http://apple.com
Success: Menu item added.

# Delete menu item
$ wp menu item delete 45
Success: Deleted 1 of 1 menu items.

wp menu item add-custom

Adds a custom menu item.

wp menu item add-custom <menu> <title> <link> [--description=<description>] [--attr-title=<attr-title>] [--target=<target>] [--classes=<classes>] [--position=<position>] [--parent-id=<parent-id>] [--porcelain]

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

<title>
	Title for the link.

<link>
	Target URL for the link.

[--description=<description>]
	Set a custom description for the menu item.

[--attr-title=<attr-title>]
	Set a custom title attribute for the menu item.

[--target=<target>]
	Set a custom link target for the menu item.

[--classes=<classes>]
	Set a custom link classes for the menu item.

[--position=<position>]
	Specify the position of this menu item.

[--parent-id=<parent-id>]
	Make this menu item a child of another menu item.

[--porcelain]
	Output just the new menu item id.

EXAMPLES

$ wp menu item add-custom sidebar-menu Apple http://apple.com
Success: Menu item added.

wp menu item add-post

Adds a post as a menu item.

wp menu item add-post <menu> <post-id> [--title=<title>] [--link=<link>] [--description=<description>] [--attr-title=<attr-title>] [--target=<target>] [--classes=<classes>] [--position=<position>] [--parent-id=<parent-id>] [--porcelain]

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

<post-id>
	Post ID to add to the menu.

[--title=<title>]
	Set a custom title for the menu item.

[--link=<link>]
	Set a custom url for the menu item.

[--description=<description>]
	Set a custom description for the menu item.

[--attr-title=<attr-title>]
	Set a custom title attribute for the menu item.

[--target=<target>]
	Set a custom link target for the menu item.

[--classes=<classes>]
	Set a custom link classes for the menu item.

[--position=<position>]
	Specify the position of this menu item.

[--parent-id=<parent-id>]
	Make this menu item a child of another menu item.

[--porcelain]
	Output just the new menu item id.

EXAMPLES

$ wp menu item add-post sidebar-menu 33 --title="Custom Test Post"
Success: Menu item added.

wp menu item add-term

Adds a taxonomy term as a menu item.

wp menu item add-term <menu> <taxonomy> <term-id> [--title=<title>] [--link=<link>] [--description=<description>] [--attr-title=<attr-title>] [--target=<target>] [--classes=<classes>] [--position=<position>] [--parent-id=<parent-id>] [--porcelain]

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

<taxonomy>
	Taxonomy of the term to be added.

<term-id>
	Term ID of the term to be added.

[--title=<title>]
	Set a custom title for the menu item.

[--link=<link>]
	Set a custom url for the menu item.

[--description=<description>]
	Set a custom description for the menu item.

[--attr-title=<attr-title>]
	Set a custom title attribute for the menu item.

[--target=<target>]
	Set a custom link target for the menu item.

[--classes=<classes>]
	Set a custom link classes for the menu item.

[--position=<position>]
	Specify the position of this menu item.

[--parent-id=<parent-id>]
	Make this menu item a child of another menu item.

[--porcelain]
	Output just the new menu item id.

EXAMPLES

$ wp menu item add-term sidebar-menu post_tag 24
Success: Menu item added.

wp menu item delete

Deletes one or more items from a menu.

wp menu item delete <db-id>...

OPTIONS

<db-id>...
	Database ID for the menu item(s).

EXAMPLES

$ wp menu item delete 45
Success: Deleted 1 of 1 menu items.

wp menu item list

Gets a list of items associated with a menu.

wp menu item list <menu> [--fields=<fields>] [--format=<format>]

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

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

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

AVAILABLE FIELDS

These fields will be displayed by default for each menu item:

  • db_id
  • type
  • title
  • link
  • position

These fields are optionally available:

  • menu_item_parent
  • object_id
  • object
  • type
  • type_label
  • target
  • attr_title
  • description
  • classes
  • xfn

EXAMPLES

$ wp menu item list main-menu
+-------+-----------+-------------+---------------------------------+----------+
| db_id | type      | title       | link                            | position |
+-------+-----------+-------------+---------------------------------+----------+
| 5     | custom    | Home        | http://example.com              | 1        |
| 6     | post_type | Sample Page | http://example.com/sample-page/ | 2        |
+-------+-----------+-------------+---------------------------------+----------+

wp menu item update

Updates a menu item.

wp menu item update <db-id> [--title=<title>] [--link=<link>] [--description=<description>] [--attr-title=<attr-title>] [--target=<target>] [--classes=<classes>] [--position=<position>] [--parent-id=<parent-id>]

OPTIONS

<db-id>
	Database ID for the menu item.

[--title=<title>]
	Set a custom title for the menu item.

[--link=<link>]
	Set a custom url for the menu item.

[--description=<description>]
	Set a custom description for the menu item.

[--attr-title=<attr-title>]
	Set a custom title attribute for the menu item.

[--target=<target>]
	Set a custom link target for the menu item.

[--classes=<classes>]
	Set a custom link classes for the menu item.

[--position=<position>]
	Specify the position of this menu item.

[--parent-id=<parent-id>]
	Make this menu item a child of another menu item.

EXAMPLES

$ wp menu item update 45 --title=WordPress --link='http://wordpress.org' --target=_blank --position=2
Success: Menu item updated.

wp menu list

Gets a list of menus.

wp menu list [--fields=<fields>] [--format=<format>]

OPTIONS

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

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

AVAILABLE FIELDS

These fields will be displayed by default for each menu:

  • term_id
  • name
  • slug
  • count

These fields are optionally available:

  • term_group
  • term_taxonomy_id
  • taxonomy
  • description
  • parent
  • locations

EXAMPLES

$ wp menu list
+---------+----------+----------+-----------+-------+
| term_id | name     | slug     | locations | count |
+---------+----------+----------+-----------+-------+
| 200     | My Menu  | my-menu  |           | 0     |
| 177     | Top Menu | top-menu | primary   | 7     |
+---------+----------+----------+-----------+-------+

wp menu location

Assigns, removes, and lists a menu's locations.

wp menu location

EXAMPLES

# List available menu locations
$ wp menu location list
+----------+-------------------+
| location | description       |
+----------+-------------------+
| primary  | Primary Menu      |
| social   | Social Links Menu |
+----------+-------------------+

# Assign the 'primary-menu' menu to the 'primary' location
$ wp menu location assign primary-menu primary
Success: Assigned location primary to menu primary-menu.

# Remove the 'primary-menu' menu from the 'primary' location
$ wp menu location remove primary-menu primary
Success: Removed location from menu.

wp menu location assign

Assigns a location to a menu.

wp menu location assign <menu> <location>

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

<location>
	Location's slug.

EXAMPLES

$ wp menu location assign primary-menu primary
Success: Assigned location primary to menu primary-menu.

wp menu location list

Lists locations for the current theme.

wp menu location list [--format=<format>]

OPTIONS

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

AVAILABLE FIELDS

These fields will be displayed by default for each location:

  • name
  • description

EXAMPLES

$ wp menu location list
+----------+-------------------+
| location | description       |
+----------+-------------------+
| primary  | Primary Menu      |
| social   | Social Links Menu |
+----------+-------------------+

wp menu location remove

Removes a location from a menu.

wp menu location remove <menu> <location>

OPTIONS

<menu>
	The name, slug, or term ID for the menu.

<location>
	Location's slug.

EXAMPLES

$ wp menu location remove primary-menu primary
Success: Removed location from menu.

wp network meta

Gets, adds, updates, deletes, and lists network custom fields.

wp network meta

EXAMPLES

# Get a list of super-admins
$ wp network meta get 1 site_admins
array (
  0 => 'supervisor',
)

wp network meta add

Add a meta field.

wp network meta add <id> <key> [<value>] [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to create.

[<value>]
	The value of the meta field. If omitted, the value is read from STDIN.

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

wp network meta delete

Delete a meta field.

wp network meta delete <id> [<key>] [<value>] [--all]

OPTIONS

<id>
	The ID of the object.

[<key>]
	The name of the meta field to delete.

[<value>]
	The value to delete. If omitted, all rows with key will deleted.

[--all]
	Delete all meta for the object.

wp network meta get

Get meta field value.

wp network meta get <id> <key> [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to get.

[--format=<format>]
	Get value in a particular format.
	---
	default: var_export
	options:
	  - var_export
	  - json
	  - yaml
	---

wp network meta list

List all metadata associated with an object.

wp network meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]

OPTIONS

<id>
	ID for the object.

[--keys=<keys>]
	Limit output to metadata of specific keys.

[--fields=<fields>]
	Limit the output to specific row fields. Defaults to id,meta_key,meta_value.

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

[--orderby=<fields>]
	Set orderby which field.
	---
	default: id
	options:
	 - id
	 - meta_key
	 - meta_value
	---

[--order=<order>]
	Set ascending or descending order.
	---
	default: asc
	options:
	 - asc
	 - desc
	---

[--unserialize]
	Unserialize meta_value output.

wp network meta patch

Update a nested value for a meta field.

wp network meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

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

<id>
	The ID of the object.

<key>
	The name of the meta field to update.

<key-path>...
	The name(s) of the keys within the value to locate the value to patch.

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

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

wp network meta pluck

Get a nested value from a meta field.

wp network meta pluck <id> <key> <key-path>... [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to get.

<key-path>...
	The name(s) of the keys within the value to locate the value to pluck.

[--format=<format>]
	The output format of the value.
	---
	default: plaintext
	options:
	  - plaintext
	  - json
	  - yaml

wp network meta update

Update a meta field.

wp network meta update <id> <key> [<value>] [--format=<format>]

OPTIONS

<id>
	The ID of the object.

<key>
	The name of the meta field to update.

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

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

wp option

Retrieves and sets site options, including plugin and WordPress settings.

wp option

See the Plugin Settings API and the Theme Options for more information on adding customized options.

EXAMPLES

# Get site URL.
$ wp option get siteurl
http://example.com

# Add option.
$ wp option add my_option foobar
Success: Added 'my_option' option.

# Update option.
$ wp option update my_option '{"foo": "bar"}' --format=json
Success: Updated 'my_option' option.

# Delete option.
$ wp option delete my_option
Success: Deleted 'my_option' option.

wp option add

Adds a new option value.

wp option add <key> [<value>] [--format=<format>] [--autoload=<autoload>]

Errors if the option already exists.

OPTIONS

<key>
	The name of the option to add.

[<value>]
	The value of the option to add. If omitted, the value is read from STDIN.

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

[--autoload=<autoload>]
	Should this option be automatically loaded.
	---
	options:
	  - 'on'
	  - 'off'
	  - 'yes'
	  - 'no'
	---

EXAMPLES

# Create an option by reading a JSON file.
$ wp option add my_option --format=json < config.json
Success: Added 'my_option' option.

wp option delete

Deletes an option.

wp option delete <key>...

OPTIONS

<key>...
	Key for the option.

EXAMPLES

# Delete an option.
$ wp option delete my_option
Success: Deleted 'my_option' option.

# Delete multiple options.
$ wp option delete option_one option_two option_three
Success: Deleted 'option_one' option.
Success: Deleted 'option_two' option.
Warning: Could not delete 'option_three' option. Does it exist?

wp option get

Gets the value for an option.

wp option get <key> [--format=<format>]

OPTIONS

<key>
	Key for the option.

[--format=<format>]
	Get value in a particular format.
	---
	default: var_export
	options:
	  - var_export
	  - json
	  - yaml
	---

EXAMPLES

# Get option.
$ wp option get home
http://example.com

# Get blog description.
$ wp option get blogdescription
A random blog description

# Get blog name
$ wp option get blogname
A random blog name

# Get admin email.
$ wp option get admin_email
someone@example.com

# Get option in JSON format.
$ wp option get active_plugins --format=json
{"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"}

wp option list

Lists options and their values.

wp option list [--search=<pattern>] [--exclude=<pattern>] [--autoload=<value>] [--transients] [--unserialize] [--field=<field>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>]

OPTIONS

[--search=<pattern>]
	Use wildcards ( * and ? ) to match option name.

[--exclude=<pattern>]
	Pattern to exclude. Use wildcards ( * and ? ) to match option name.

[--autoload=<value>]
	Match only autoload options when value is on, and only not-autoload option when off.

[--transients]
	List only transients. Use `--no-transients` to ignore all transients.

[--unserialize]
	Unserialize option values in output.

[--field=<field>]
	Prints the value of a single field.

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

[--format=<format>]
	The serialization format for the value. total_bytes displays the total size of matching options in bytes.
	---
	default: table
	options:
	  - table
	  - json
	  - csv
	  - count
	  - yaml
	  - total_bytes
	---

[--orderby=<fields>]
	Set orderby which field.
	---
	default: option_id
	options:
	 - option_id
	 - option_name
	 - option_value
	---

[--order=<order>]
	Set ascending or descending order.
	---
	default: asc
	options:
	 - asc
	 - desc
	---

AVAILABLE FIELDS

This field will be displayed by default for each matching option:

  • option_name
  • option_value

These fields are optionally available:

  • autoload
  • size_bytes

EXAMPLES

# Get the total size of all autoload options.
$ wp option list --autoload=on --format=total_bytes
33198

# Find biggest transients.
$ wp option list --search="*_transient_*" --fields=option_name,size_bytes | sort -n -k 2 | tail
option_name size_bytes
_site_transient_timeout_theme_roots 10
_site_transient_theme_roots 76
_site_transient_update_themes   181
_site_transient_update_core 808
_site_transient_update_plugins  6645

# List all options beginning with "i2f_".
$ wp option list --search="i2f_*"
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
| i2f_version | 0.1.0        |
+-------------+--------------+

# Delete all options beginning with "theme_mods_".
$ wp option list --search="theme_mods_*" --field=option_name | xargs -I % wp option delete %
Success: Deleted 'theme_mods_twentysixteen' option.
Success: Deleted 'theme_mods_twentyfifteen' option.
Success: Deleted 'theme_mods_twentyfourteen' option.

wp option patch

Updates a nested value in an option.

wp option patch <action> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

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

<key>
	The option name.

<key-path>...
	The name(s) of the keys within the value to locate the value to patch.

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

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

EXAMPLES

# Add 'bar' to the 'foo' key on an option with name 'option_name'
$ wp option patch insert option_name foo bar
Success: Updated 'option_name' option.

# Update the value of 'foo' key to 'new' on an option with name 'option_name'
$ wp option patch update option_name foo new
Success: Updated 'option_name' option.

# Set nested value of 'bar' key to value we have in the patch file on an option with name 'option_name'.
$ wp option patch update option_name foo bar < patch
Success: Updated 'option_name' option.

# Update the value for the key 'not-a-key' which is not exist on an option with name 'option_name'.
$ wp option patch update option_name foo not-a-key new-value
Error: No data exists for key "not-a-key"

# Update the value for the key 'foo' without passing value on an option with name 'option_name'.
$ wp option patch update option_name foo
Error: Please provide value to update.

# Delete the nested key 'bar' under 'foo' key on an option with name 'option_name'.
$ wp option patch delete option_name foo bar
Success: Updated 'option_name' option.

wp option pluck

Gets a nested value from an option.

wp option pluck <key> <key-path>... [--format=<format>]

OPTIONS

<key>
	The option name.

<key-path>...
	The name(s) of the keys within the value to locate the value to pluck.

[--format=<format>]
	The output format of the value.
	---
	default: plaintext
	options:
	  - plaintext
	  - json
	  - yaml
	---

wp option update

Updates an option value.

wp option update <key> [<value>] [--autoload=<autoload>] [--format=<format>]

OPTIONS