Manage WordPress comments, menus, options, posts, sites, terms, and users.
Quick links: Using | Installing | Contributing | Support
This package implements the following commands:
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.
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.
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
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.
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.
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.
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.
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!
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 |
+------------+---------------------+----------------+
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.
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
---
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.
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
---
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.
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
---
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
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
---
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 |
+-------+-----------+-------------+---------------------------------+----------+
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.
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 |
+---------+----------+----------+-----------+-------+
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.
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.
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 |
+----------+-------------------+
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.
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',
)
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
---
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.
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
---
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.
Update a nested value for a meta field.
wp network meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
OPTIONS
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="<action> Patch action to perform. --- options: - insert - update - delete --- <id> The ID of the object. <key> The name o