Search by

wp-cli / entity-command

danielbachhuberschlessera

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

Package info

github.com/wp-cli/entity-command

Type:wp-cli-package

pkg:composer/wp-cli/entity-command

Statistics

Installs: 10 862 750

Dependents: 50

Suggesters: 0

Stars: 105

Open Issues: 6


README

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

Testing Code Coverage

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.

# Create a note for a block (WordPress 6.9+).
$ wp comment create --comment_post_ID=15 --comment_content="This block needs revision" --comment_author="editor" --comment_type="note"
Success: Created comment 945.

# List notes for a specific post (WordPress 6.9+).
$ wp comment list --type=note --post_id=15
+------------+---------------------+----------------------------------+
| comment_ID | comment_date        | comment_content                  |
+------------+---------------------+----------------------------------+
| 945        | 2024-11-10 14:30:00 | This block needs revision        |
+------------+---------------------+----------------------------------+

# Reply to a note (WordPress 6.9+).
$ wp comment create --comment_post_ID=15 --comment_content="Updated per feedback" --comment_author="editor" --comment_type="note" --comment_parent=945
Success: Created comment 946.

# Resolve a note by adding a comment with status meta (WordPress 6.9+).
$ wp comment create --comment_post_ID=15 --comment_content="Resolving" --comment_author="editor" --comment_type="note" --comment_parent=945 --porcelain
947
$ wp comment meta add 947 _wp_note_status resolved
Success: Added custom field.

# Reopen a resolved note (WordPress 6.9+).
$ wp comment create --comment_post_ID=15 --comment_content="Reopening for further review" --comment_author="editor" --comment_type="note" --comment_parent=945 --porcelain
948
$ wp comment meta add 948 _wp_note_status reopen
Success: Added custom field.

wp comment approve

Approves a comment.

wp comment approve ...

OPTIONS

...
	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 []

OPTIONS

[]
	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 [--comment_agent=] [--comment_approved=] [--comment_author=] [--comment_author_email=] [--comment_author_IP=] [--comment_author_url=] [--comment_content=] [--comment_date=] [--comment_date_gmt=] [--comment_karma=] [--comment_parent=] [--comment_post_ID=] [--comment_type=] [--comment_meta=] [--user_id=] [--=] [--porcelain]

OPTIONS

[--comment_agent=]
	The HTTP user agent of the comment author.

[--comment_approved=]
	Whether the comment has been approved. Default 1.

[--comment_author=]
	The name of the author of the comment.

[--comment_author_email=]
	The email address of the comment author.

[--comment_author_IP=]
	The IP address of the comment author.

[--comment_author_url=]
	The URL address of the comment author.

[--comment_content=]
	The content of the comment.

[--comment_date=]
	The date the comment was submitted.

[--comment_date_gmt=]
	The date the comment was submitted in the GMT timezone.

[--comment_karma=]
	The karma of the comment. Default 0.

[--comment_parent=]
	ID of this comment's parent, if any. Default 0.

[--comment_post_ID=]
	ID of the post that relates to the comment, if any.

[--comment_type=]
	Comment type. Default 'comment'.

[--comment_meta=]
	Array in JSON format of comment meta values keyed by their comment meta key.

[--user_id=]
	ID of the user who submitted the comment. Default 0.

[--=]
	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.

# Create a note (WordPress 6.9+).
$ wp comment create --comment_post_ID=15 --comment_content="This block needs revision" --comment_author="editor" --comment_type="note"
Success: Created comment 933.

wp comment delete

Deletes a comment.

wp comment delete ... [--force]

OPTIONS

...
	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 

Displays a success message if the comment does exist.

OPTIONS


	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=] [--post_id=] [--format=]

Creates a specified number of new comments with dummy data.

OPTIONS

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

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

[--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  [--field=] [--fields=] [--format=]

OPTIONS


	The comment to get.

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

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

[--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=] [--fields=] [--format=]

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

OPTIONS

[--=]
	One or more args to pass to WP_Comment_Query.

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

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

[--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       |
+------------+---------------------+----------------+

# List notes for a specific post (WordPress 6.9+).
$ wp comment list --type=note --post_id=15 --fields=ID,comment_date,comment_content
+------------+---------------------+----------------------------------+
| comment_ID | comment_date        | comment_content                  |
+------------+---------------------+----------------------------------+
| 10         | 2024-11-10 14:30:00 | This block needs revision        |
| 11         | 2024-11-10 15:45:00 | Updated per feedback             |
+------------+---------------------+----------------------------------+

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   [] [--format=]

OPTIONS


	The ID of the object.


	The name of the meta field to create.

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

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

wp comment meta delete

Delete a meta field.

wp comment meta delete  [] [] [--all]

OPTIONS


	The ID of the object.

[]
	The name of the meta field to delete.

[]
	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   [--single] [--format=]

OPTIONS


	The ID of the object.


	The name of the meta field to get.

[--single]
	Whether to return a single value.

[--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  [--keys=] [--fields=] [--format=] [--orderby=] [--order=] [--unserialize]

OPTIONS


	ID for the object.

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

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

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

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

[--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    ... [] [--format=]

OPTIONS


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


	The ID of the object.


	The name of the meta field to update.

...
	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
	---

wp comment meta pluck

Get a nested value from a meta field.

wp comment meta pluck   ... [--format=]

OPTIONS


	The ID of the object.


	The name of the meta field to get.

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

[--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   [] [--format=]

Alias: set

OPTIONS


	The ID of the object.


	The name of the meta field to update.

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

[--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 ...

OPTIONS

...
	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 ...

OPTIONS

...
	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 

OPTIONS


	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 ...

OPTIONS

...
	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 ...

OPTIONS

...
	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 ...

OPTIONS

...
	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 ...

OPTIONS

...
	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 ... [--comment_agent=] [--comment_approved=] [--comment_author=] [--comment_author_email=] [--comment_author_IP=] [--comment_author_url=] [--comment_content=] [--comment_date=] [--comment_date_gmt=] [--comment_karma=] [--comment_parent=] [--comment_post_ID=] [--comment_type=] [--comment_meta=] [--user_id=] --=

OPTIONS

...
	One or more IDs of comments to update.

[--comment_agent=]
	The HTTP user agent of the comment author.

[--comment_approved=]
	Whether the comment has been approved.

[--comment_author=]
	The name of the author of the comment.

[--comment_author_email=]
	The email address of the comment author.

[--comment_author_IP=]
	The IP address of the comment author.

[--comment_author_url=]
	The URL address of the comment author.

[--comment_content=]
	The content of the comment.

[--comment_date=]
	The date the comment was submitted.

[--comment_date_gmt=]
	The date the comment was submitted in the GMT timezone. Note that
	wp_update_comment() always recalculates this from 'comment_date'.

[--comment_karma=]
	The karma of the comment.

[--comment_parent=]
	ID of this comment's parent, if any.

[--comment_post_ID=]
	ID of the post that relates to the comment, if any.

[--comment_type=]
	Comment type.

[--comment_meta=]
	Array in JSON format of comment meta values keyed by their comment meta key.

[--user_id=]
	ID of the user who submitted the comment.

--=
	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 font

Manages WordPress fonts.

wp font

EXAMPLES

# List all font collections
$ wp font collection list

# Install a font family from a collection
$ wp font family install google-fonts inter

# List installed font families
$ wp post list --post_type=wp_font_family

# List installed font faces
$ wp post list --post_type=wp_font_face

wp font collection

Manages font collections.

wp font collection

Font collections are predefined sets of fonts that can be used in WordPress. Collections are registered by WordPress core or themes and cannot be created or deleted via the command line.

EXAMPLES

# List all font collections
$ wp font collection list
+------------------+-------------------+---------+
| slug             | name              | count   |
+------------------+-------------------+---------+
| google-fonts     | Google Fonts      | 1500    |
+------------------+-------------------+---------+

# Get details about a specific font collection
$ wp font collection get google-fonts
+-------+------------------+
| Field | Value            |
+-------+------------------+
| slug  | google-fonts     |
| name  | Google Fonts     |
+-------+------------------+

wp font collection get

Gets details about a registered font collection.

wp font collection get  [--field=] [--fields=] [--format=]

OPTIONS


	Font collection slug.

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

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

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

AVAILABLE FIELDS

These fields will be displayed by default for the specified collection:

  • slug
  • name
  • description
  • categories

EXAMPLES

# Get details of a specific collection
$ wp font collection get google-fonts
+-------+------------------+
| Field | Value            |
+-------+------------------+
| slug  | google-fonts     |
| name  | Google Fonts     |
+-------+------------------+

# Get the name field only
$ wp font collection get google-fonts --field=name
Google Fonts

wp font collection is-registered

Checks if a font collection is registered.

wp font collection is-registered 

OPTIONS


	Font collection slug.

EXAMPLES

# Bash script for checking if a font collection is registered, with fallback.

if wp font collection is-registered google-fonts 2>/dev/null; then
    # Font collection is registered. Do something.
else
    # Fallback if collection is not registered.
fi

wp font collection list

Lists registered font collections.

wp font collection list [--field=] [--fields=] [--format=]

OPTIONS

[--field=]
	Prints the value of a single field for each collection.

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

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

AVAILABLE FIELDS

These fields will be displayed by default for each collection:

  • slug
  • name
  • description
  • categories

EXAMPLES

# List all font collections
$ wp font collection list
+------------------+-------------------+
| slug             | name              |
+------------------+-------------------+
| google-fonts     | Google Fonts      |
+------------------+-------------------+

# List collections in JSON format
$ wp font collection list --format=json
[{"slug":"google-fonts","name":"Google Fonts"}]

wp font collection list-categories

Lists categories in a collection.

wp font collection list-categories  [--field=] [--fields=] [--format=]

OPTIONS


	Font collection slug.

[--field=]
	Prints the value of a single field for each category.

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

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

AVAILABLE FIELDS

  • slug
  • name

EXAMPLES

# List all categories in a collection
$ wp font collection list-categories google-fonts
+-------------+--------------+
| slug        | name         |
+-------------+--------------+
| sans-serif  | Sans Serif   |
| display     | Display      |
+-------------+--------------+

wp font collection list-families

Lists font families in a collection.

wp font collection list-families  [--category=] [--field=] [--fields=] [--format=]

OPTIONS


	Font collection slug.

[--category=]
	Filter by category slug.

[--field=]
	Prints the value of a single field for each family.

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

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

AVAILABLE FIELDS

  • slug
  • name
  • fontFamily
  • categories
  • preview

EXAMPLES

# List all font families in a collection
$ wp font collection list-families google-fonts

# List font families in a specific category
$ wp font collection list-families google-fonts --category=sans-serif

wp font face

Manages font faces.

wp font face

To list, get, create, update or delete font faces, use wp post with --post_type=wp_font_face.

EXAMPLES

# Install a font face for an existing family
$ wp font face install 42 --src="https://example.com/font.woff2" --font-weight=700
Success: Created font face 43.

# List installed font faces
$ wp post list --post_type=wp_font_face

wp font face install

Installs a font face.

wp font face install  --src= [--font-family=] [--font-style=