wp-cli / entity-command
管理WordPress评论、菜单、选项、帖子、站点、术语和用户。
Requires
- wp-cli/wp-cli: ^2.11
Requires (Dev)
- wp-cli/cache-command: ^1 || ^2
- wp-cli/db-command: ^1.3 || ^2
- wp-cli/extension-command: ^1.2 || ^2
- wp-cli/media-command: ^1.1 || ^2
- wp-cli/super-admin-command: ^1 || ^2
- wp-cli/wp-cli-tests: ^4
- dev-main / 2.x-dev
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-bump-framework-2-11
- dev-regenerate-readme
- dev-205-specify-entities
- dev-issue-134-meta_input-usage-warning
- dev-update-testing-framework
This package is auto-updated.
Last update: 2024-09-12 07:54:25 UTC
README
管理WordPress评论、菜单、选项、帖子、站点、术语和用户。
使用
此包实现了以下命令
wp comment
创建、更新、删除和监控评论。
wp comment
示例
# 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
批准一条评论。
wp comment approve <id>...
选项
<id>...
The IDs of the comments to approve.
示例
# Approve comment.
$ wp comment approve 1337
Success: Approved comment 1337.
wp comment count
计算评论数量,在整个博客或特定帖子中。
wp comment count [<post-id>]
选项
[<post-id>]
The ID of the post to count comments in.
示例
# 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
创建新的评论。
wp comment create [--<field>=<value>] [--porcelain]
选项
[--<field>=<value>]
Associative args for the new comment. See wp_insert_comment().
[--porcelain]
Output just the new comment id.
示例
# Create comment.
$ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
Success: Created comment 932.
wp comment delete
删除评论。
wp comment delete <id>... [--force]
选项
<id>...
One or more IDs of comments to delete.
[--force]
Skip the trash bin.
示例
# 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
验证评论是否存在。
wp comment exists <id>
如果评论存在,显示成功消息。
选项
<id>
The ID of the comment to check.
示例
# Check whether comment exists.
$ wp comment exists 1337
Success: Comment with ID 1337 exists.
wp comment generate
生成一定数量的模拟评论。
wp comment generate [--count=<number>] [--post_id=<post-id>] [--format=<format>]
使用模拟数据创建指定数量的新评论。
选项
[--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
---
示例
# 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
获取单个评论的数据。
wp comment get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<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
---
示例
# Get comment.
$ wp comment get 21 --field=content
Thanks for all the comments, everyone!
wp comment list
获取评论列表。
wp comment list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
基于WP_Comment_Query()支持的所有参数显示评论。
选项
[--<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
---
可用字段
以下字段将默认显示在每个评论中
- comment_ID
- comment_post_ID
- comment_date
- comment_approved
- comment_author
- comment_author_email
以下字段为可选字段
- comment_author_url
- comment_author_IP
- comment_date_gmt
- comment_content
- comment_karma
- comment_agent
- comment_type
- comment_parent
- user_id
- url
示例
# 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
添加、更新、删除和列出评论自定义字段。
wp comment meta
示例
# 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
添加元字段。
wp comment meta add <id> <key> [<value>] [--format=<format>]
选项
<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
删除元字段。
wp comment meta delete <id> [<key>] [<value>] [--all]
选项
<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
获取元字段值。
wp comment meta get <id> <key> [--format=<format>]
选项
<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
列出与对象关联的所有元数据。
wp comment meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<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
更新元字段的嵌套值。
wp comment meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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
从元字段获取嵌套值。
wp comment meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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
更新元字段。
wp comment meta update <id> <key> [<value>] [--format=<format>]
选项
<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
重新计算一个或多个帖子的 comment_count 值。
wp comment recount <id>...
选项
<id>...
IDs for one or more posts to update.
示例
# Recount comment for the post.
$ wp comment recount 123
Updated post 123 comment count to 67.
wp comment spam
将评论标记为垃圾邮件。
wp comment spam <id>...
选项
<id>...
The IDs of the comments to mark as spam.
示例
# Spam comment.
$ wp comment spam 1337
Success: Marked as spam comment 1337.
wp comment status
获取评论的状态。
wp comment status <id>
选项
<id>
The ID of the comment to check.
示例
# Get status of comment.
$ wp comment status 1337
approved
wp comment trash
将评论移动到回收站。
wp comment trash <id>...
选项
<id>...
The IDs of the comments to trash.
示例
# Trash comment.
$ wp comment trash 1337
Success: Trashed comment 1337.
wp comment unapprove
取消批准评论。
wp comment unapprove <id>...
选项
<id>...
The IDs of the comments to unapprove.
示例
# Unapprove comment.
$ wp comment unapprove 1337
Success: Unapproved comment 1337.
wp comment unspam
取消将评论标记为垃圾邮件。
wp comment unspam <id>...
选项
<id>...
The IDs of the comments to unmark as spam.
示例
# Unspam comment.
$ wp comment unspam 1337
Success: Unspammed comment 1337.
wp comment untrash
取消将评论从回收站恢复。
wp comment untrash <id>...
选项
<id>...
The IDs of the comments to untrash.
示例
# Untrash comment.
$ wp comment untrash 1337
Success: Untrashed comment 1337.
wp comment update
更新一个或多个评论。
wp comment update <id>... --<field>=<value>
选项
<id>...
One or more IDs of comments to update.
--<field>=<value>
One or more fields to update. See wp_update_comment().
示例
# Update comment.
$ wp comment update 123 --comment_author='That Guy'
Success: Updated comment 123.
wp menu
列出、创建、分配和删除活动主题的导航菜单。
wp menu
参见主题手册中的导航菜单参考。
示例
# 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
创建新的菜单。
wp menu create <menu-name> [--porcelain]
选项
<menu-name>
A descriptive name for the menu.
[--porcelain]
Output just the new menu id.
示例
$ wp menu create "My Menu"
Success: Created menu 200.
wp menu delete
删除一个或多个菜单。
wp menu delete <menu>...
选项
<menu>...
The name, slug, or term ID for the menu(s).
示例
$ wp menu delete "My Menu"
Deleted menu 'My Menu'.
Success: Deleted 1 of 1 menus.
wp 菜单项
列表、添加和删除与菜单关联的项目。
wp menu item
示例
# 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 菜单项 添加自定义
添加自定义菜单项。
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]
选项
<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.
示例
$ wp menu item add-custom sidebar-menu Apple http://apple.com
Success: Menu item added.
wp 菜单项 添加文章
将文章添加为菜单项。
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]
选项
<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.
示例
$ wp menu item add-post sidebar-menu 33 --title="Custom Test Post"
Success: Menu item added.
wp 菜单项 添加术语
将分类术语添加为菜单项。
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]
选项
<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.
示例
$ wp menu item add-term sidebar-menu post_tag 24
Success: Menu item added.
wp 菜单项 删除
从菜单中删除一个或多个项目。
wp menu item delete <db-id>...
选项
<db-id>...
Database ID for the menu item(s).
示例
$ wp menu item delete 45
Success: Deleted 1 of 1 menu items.
wp 菜单项 列表
获取与菜单关联的项目列表。
wp menu item list <menu> [--fields=<fields>] [--format=<format>]
选项
<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
---
可用字段
这些字段将默认显示在每个菜单项中
- db_id
- type
- title
- link
- position
以下字段为可选字段
- menu_item_parent
- object_id
- object
- type
- type_label
- target
- attr_title
- description
- classes
- xfn
示例
$ 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 菜单项 更新
更新菜单项。
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>]
选项
<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.
示例
$ wp menu item update 45 --title=WordPress --link='http://wordpress.org' --target=_blank --position=2
Success: Menu item updated.
wp 菜单 列表
获取菜单列表。
wp menu list [--fields=<fields>] [--format=<format>]
选项
[--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
---
可用字段
这些字段将默认显示在每个菜单中
- term_id
- name
- slug
- count
以下字段为可选字段
- term_group
- term_taxonomy_id
- taxonomy
- description
- parent
- locations
示例
$ wp menu list
+---------+----------+----------+-----------+-------+
| term_id | name | slug | locations | count |
+---------+----------+----------+-----------+-------+
| 200 | My Menu | my-menu | | 0 |
| 177 | Top Menu | top-menu | primary | 7 |
+---------+----------+----------+-----------+-------+
wp 菜单 位置
分配、删除和列出菜单的位置。
wp menu location
示例
# 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 菜单 位置 分配
将位置分配给菜单。
wp menu location assign <menu> <location>
选项
<menu>
The name, slug, or term ID for the menu.
<location>
Location's slug.
示例
$ wp menu location assign primary-menu primary
Success: Assigned location primary to menu primary-menu.
wp 菜单 位置 列表
列出当前主题的位置。
wp menu location list [--format=<format>]
选项
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- count
- yaml
- ids
---
可用字段
这些字段将默认显示在每个位置中
- name
- description
示例
$ wp menu location list
+----------+-------------------+
| location | description |
+----------+-------------------+
| primary | Primary Menu |
| social | Social Links Menu |
+----------+-------------------+
wp 菜单 位置 删除
从菜单中删除位置。
wp menu location remove <menu> <location>
选项
<menu>
The name, slug, or term ID for the menu.
<location>
Location's slug.
示例
$ wp menu location remove primary-menu primary
Success: Removed location from menu.
wp 网络元数据
获取、添加、更新、删除和列出网络自定义字段。
wp network meta
示例
# Get a list of super-admins
$ wp network meta get 1 site_admins
array (
0 => 'supervisor',
)
wp 网络元数据 添加
添加元字段。
wp network meta add <id> <key> [<value>] [--format=<format>]
选项
<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 网络元数据 删除
删除元字段。
wp network meta delete <id> [<key>] [<value>] [--all]
选项
<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 网络元数据 获取
获取元字段值。
wp network meta get <id> <key> [--format=<format>]
选项
<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 网络元数据 列表
列出与对象关联的所有元数据。
wp network meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<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 网络元数据 补丁
更新元字段的嵌套值。
wp network meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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 网络元数据 提取
从元字段获取嵌套值。
wp network meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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 网络元数据 更新
更新元字段。
wp network meta update <id> <key> [<value>] [--format=<format>]
选项
<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 选项
检索和设置站点选项,包括插件和 WordPress 设置。
wp option
有关添加自定义选项的更多信息,请参阅插件设置 API和主题选项。
示例
# 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 选项 添加
添加新的选项值。
wp option add <key> [<value>] [--format=<format>] [--autoload=<autoload>]
如果选项已存在,则出错。
选项
<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'
---
示例
# Create an option by reading a JSON file.
$ wp option add my_option --format=json < config.json
Success: Added 'my_option' option.
wp 选项 删除
删除选项。
wp option delete <key>...
选项
<key>...
Key for the option.
示例
# 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 选项 获取
获取选项的值。
wp option get <key> [--format=<format>]
选项
<key>
Key for the option.
[--format=<format>]
Get value in a particular format.
---
default: var_export
options:
- var_export
- json
- yaml
---
示例
# 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
[email protected]
# 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 选项 列表
列出选项及其值。
wp option list [--search=<pattern>] [--exclude=<pattern>] [--autoload=<value>] [--transients] [--unserialize] [--field=<field>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>]
选项
[--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
---
可用字段
这些字段将默认显示在每个匹配的选项中
- option_name
- option_value
以下字段为可选字段
- autoload
- size_bytes
示例
# 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 选项 补丁
更新选项中的嵌套值。
wp option patch <action> <key> <key-path>... [<value>] [--format=<format>]
选项
<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
---
示例
# 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 选项 提取
从选项中获取嵌套值。
wp option pluck <key> <key-path>... [--format=<format>]
选项
<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 选项 更新
更新选项值。
wp option update <key> [<value>] [--autoload=<autoload>] [--format=<format>]
选项
<key>
The name of the option to update.
[<value>]
The new value. If omitted, the value is read from STDIN.
[--autoload=<autoload>]
Requires WP 4.2. Should this option be automatically loaded.
---
options:
- 'on'
- 'off'
- 'yes'
- 'no'
---
[--format=<format>]
The serialization format for the value.
---
default: plaintext
options:
- plaintext
- json
---
示例
# Update an option by reading from a file.
$ wp option update my_option < value.txt
Success: Updated 'my_option' option.
# Update one option on multiple sites using xargs.
$ wp site list --field=url | xargs -n1 -I {} sh -c 'wp --url={} option update my_option my_value'
Success: Updated 'my_option' option.
Success: Updated 'my_option' option.
# Update site blog name.
$ wp option update blogname "Random blog name"
Success: Updated 'blogname' option.
# Update site blog description.
$ wp option update blogdescription "Some random blog description"
Success: Updated 'blogdescription' option.
# Update admin email address.
$ wp option update admin_email [email protected]
Success: Updated 'admin_email' option.
# Set the default role.
$ wp option update default_role author
Success: Updated 'default_role' option.
# Set the timezone string.
$ wp option update timezone_string "America/New_York"
Success: Updated 'timezone_string' option.
wp 选项 设置-autoload
设置选项的 'autoload' 值。
wp option set-autoload <key> <autoload>
选项
<key>
The name of the option to set 'autoload' for.
<autoload>
Should this option be automatically loaded.
---
options:
- 'on'
- 'off'
- 'yes'
- 'no'
---
示例
# Set the 'autoload' value for an option.
$ wp option set-autoload abc_options no
Success: Updated autoload value for 'abc_options' option.
wp 选项 获取-autoload
获取选项的 'autoload' 值。
wp option get-autoload <key>
选项
<key>
The name of the option to get 'autoload' of.
示例
# Get the 'autoload' value for an option.
$ wp option get-autoload blogname
yes
wp 文章
管理文章、内容和元数据。
wp post
示例
# Create a new post.
$ wp post create --post_type=post --post_title='A sample post'
Success: Created post 123.
# Update an existing post.
$ wp post update 123 --post_status=draft
Success: Updated post 123.
# Delete an existing post.
$ wp post delete 123
Success: Trashed post 123.
wp 文章 创建
创建新文章。
wp post create [--post_author=<post_author>] [--post_date=<post_date>] [--post_date_gmt=<post_date_gmt>] [--post_content=<post_content>] [--post_content_filtered=<post_content_filtered>] [--post_title=<post_title>] [--post_excerpt=<post_excerpt>] [--post_status=<post_status>] [--post_type=<post_type>] [--comment_status=<comment_status>] [--ping_status=<ping_status>] [--post_password=<post_password>] [--post_name=<post_name>] [--from-post=<post_id>] [--to_ping=<to_ping>] [--pinged=<pinged>] [--post_modified=<post_modified>] [--post_modified_gmt=<post_modified_gmt>] [--post_parent=<post_parent>] [--menu_order=<menu_order>] [--post_mime_type=<post_mime_type>] [--guid=<guid>] [--post_category=<post_category>] [--tags_input=<tags_input>] [--tax_input=<tax_input>] [--meta_input=<meta_input>] [<file>] [--<field>=<value>] [--edit] [--porcelain]
选项
[--post_author=<post_author>]
The ID of the user who added the post. Default is the current user ID.
[--post_date=<post_date>]
The date of the post. Default is the current time.
[--post_date_gmt=<post_date_gmt>]
The date of the post in the GMT timezone. Default is the value of $post_date.
[--post_content=<post_content>]
The post content. Default empty.
[--post_content_filtered=<post_content_filtered>]
The filtered post content. Default empty.
[--post_title=<post_title>]
The post title. Default empty.
[--post_excerpt=<post_excerpt>]
The post excerpt. Default empty.
[--post_status=<post_status>]
The post status. Default 'draft'.
[--post_type=<post_type>]
The post type. Default 'post'.
[--comment_status=<comment_status>]
Whether the post can accept comments. Accepts 'open' or 'closed'. Default is the value of 'default_comment_status' option.
[--ping_status=<ping_status>]
Whether the post can accept pings. Accepts 'open' or 'closed'. Default is the value of 'default_ping_status' option.
[--post_password=<post_password>]
The password to access the post. Default empty.
[--post_name=<post_name>]
The post name. Default is the sanitized post title when creating a new post.
[--from-post=<post_id>]
Post id of a post to be duplicated.
[--to_ping=<to_ping>]
Space or carriage return-separated list of URLs to ping. Default empty.
[--pinged=<pinged>]
Space or carriage return-separated list of URLs that have been pinged. Default empty.
[--post_modified=<post_modified>]
The date when the post was last modified. Default is the current time.
[--post_modified_gmt=<post_modified_gmt>]
The date when the post was last modified in the GMT timezone. Default is the current time.
[--post_parent=<post_parent>]
Set this for the post it belongs to, if any. Default 0.
[--menu_order=<menu_order>]
The order the post should be displayed in. Default 0.
[--post_mime_type=<post_mime_type>]
The mime type of the post. Default empty.
[--guid=<guid>]
Global Unique ID for referencing the post. Default empty.
[--post_category=<post_category>]
Array of category names, slugs, or IDs. Defaults to value of the 'default_category' option.
[--tags_input=<tags_input>]
Array of tag names, slugs, or IDs. Default empty.
[--tax_input=<tax_input>]
Array of taxonomy terms keyed by their taxonomy name. Default empty.
[--meta_input=<meta_input>]
Array in JSON format of post meta values keyed by their post meta key. Default empty.
[<file>]
Read post content from <file>. If this value is present, the
`--post_content` argument will be ignored.
将 -
作为文件名传递会导致从 STDIN 读取文章内容。
[--<field>=<value>]
Associative args for the new post. See wp_insert_post().
[--edit]
Immediately open system's editor to write or edit post content.
如果从文件、STDIN 或 --post_content
参数读取内容,该文本将被加载到编辑器中。
[--porcelain]
Output just the new post id.
示例
# Create post and schedule for future
$ wp post create --post_type=post --post_title='A future post' --post_status=future --post_date='2030-12-01 07:00:00'
Success: Created post 1921.
# Create post with content from given file
$ wp post create ./post-content.txt --post_category=201,345 --post_title='Post from file'
Success: Created post 1922.
# Create a post with multiple meta values.
$ wp post create --post_title='A post' --post_content='Just a small post.' --meta_input='{"key1":"value1","key2":"value2"}'
Success: Created post 1923.
# Create a duplicate post from existing posts.
$ wp post create --from-post=123 --post_title='Different Title'
Success: Created post 2350.
wp 文章 删除
删除现有文章。
wp post delete <id>... [--force] [--defer-term-counting]
选项
<id>...
One or more IDs of posts to delete.
[--force]
Skip the trash bin.
[--defer-term-counting]
Recalculate term count in batch, for a performance boost.
示例
# Delete post skipping trash
$ wp post delete 123 --force
Success: Deleted post 123.
# Delete multiple posts
$ wp post delete 123 456 789
Success: Trashed post 123.
Success: Trashed post 456.
Success: Trashed post 789.
# Delete all pages
$ wp post delete $(wp post list --post_type='page' --format=ids)
Success: Trashed post 1164.
Success: Trashed post 1186.
# Delete all posts in the trash
$ wp post delete $(wp post list --post_status=trash --format=ids)
Success: Deleted post 1268.
Success: Deleted post 1294.
wp 文章 编辑
启动系统编辑器以编辑文章内容。
wp post edit <id>
选项
<id>
The ID of the post to edit.
示例
# Launch system editor to edit post
$ wp post edit 123
wp 文章 存在
验证文章是否存在。
wp post exists <id>
如果文章确实存在,则显示成功消息。
选项
<id>
The ID of the post to check.
示例
# The post exists.
$ wp post exists 1337
Success: Post with ID 1337 exists.
$ echo $?
0
# The post does not exist.
$ wp post exists 10000
$ echo $?
1
wp 文章 生成
生成一些文章。
wp post generate [--count=<number>] [--post_type=<type>] [--post_status=<status>] [--post_title=<post_title>] [--post_author=<login>] [--post_date=<yyyy-mm-dd-hh-ii-ss>] [--post_date_gmt=<yyyy-mm-dd-hh-ii-ss>] [--post_content] [--max_depth=<number>] [--format=<format>]
使用虚拟数据创建指定数量的新文章。
选项
[--count=<number>]
How many posts to generate?
---
default: 100
---
[--post_type=<type>]
The type of the generated posts.
---
default: post
---
[--post_status=<status>]
The status of the generated posts.
---
default: publish
---
[--post_title=<post_title>]
The post title.
---
default:
---
[--post_author=<login>]
The author of the generated posts.
---
default:
---
[--post_date=<yyyy-mm-dd-hh-ii-ss>]
The date of the post. Default is the current time.
[--post_date_gmt=<yyyy-mm-dd-hh-ii-ss>]
The date of the post in the GMT timezone. Default is the value of --post_date.
[--post_content]
If set, the command reads the post_content from STDIN.
[--max_depth=<number>]
For hierarchical post types, generate child posts down to a certain depth.
---
default: 1
---
[--format=<format>]
Render output in a particular format.
---
default: progress
options:
- progress
- ids
---
示例
# Generate posts.
$ wp post generate --count=10 --post_type=page --post_date=1999-01-04
Generating posts 100% [================================================] 0:01 / 0:04
# Generate posts with fetched content.
$ curl -N https://loripsum.net/api/5 | wp post generate --post_content --count=10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2509 100 2509 0 0 616 0 0:00:04 0:00:04 --:--:-- 616
Generating posts 100% [================================================] 0:01 / 0:04
# Add meta to every generated posts.
$ wp post generate --format=ids | xargs -d ' ' -I % wp post meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.
wp 文章 获取
获取文章的详细信息。
wp post get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<id>
The ID of the post to get.
[--field=<field>]
Instead of returning the whole post, 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
---
示例
# Save the post content to a file
$ wp post get 123 --field=content > file.txt
wp 文章 列表
获取文章列表。
wp post list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
根据 WP_Query() 支持的所有参数显示文章。默认情况下仅显示标记为文章的文章类型。
选项
[--<field>=<value>]
One or more args to pass to WP_Query.
[--field=<field>]
Prints the value of a single field for each post.
[--fields=<fields>]
Limit the output to specific object fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- ids
- json
- count
- yaml
---
可用字段
这些字段将默认显示在每个文章中
- ID
- post_title
- post_name
- post_date
- post_status
以下字段为可选字段
- 发布作者
- GMT时间发布的日期
- 发布内容
- 摘录
- 评论状态
- ping状态
- 发布密码
- 待ping
- 已ping
- 修改日期
- GMT时间修改日期
- 过滤后的内容
- 父帖子
- GUID
- 菜单顺序
- 帖子类型
- 媒体类型
- 评论数量
- 过滤器
- url
示例
# List post
$ wp post list --field=ID
568
829
1329
1695
# List posts in JSON
$ wp post list --post_type=post --posts_per_page=5 --format=json
[{"ID":1,"post_title":"Hello world!","post_name":"hello-world","post_date":"2015-06-20 09:00:10","post_status":"publish"},{"ID":1178,"post_title":"Markup: HTML Tags and Formatting","post_name":"markup-html-tags-and-formatting","post_date":"2013-01-11 20:22:19","post_status":"draft"}]
# List all pages
$ wp post list --post_type=page --fields=post_title,post_status
+-------------+-------------+
| post_title | post_status |
+-------------+-------------+
| Sample Page | publish |
+-------------+-------------+
# List ids of all pages and posts
$ wp post list --post_type=page,post --format=ids
15 25 34 37 198
# List given posts
$ wp post list --post__in=1,3
+----+--------------+-------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+----+--------------+-------------+---------------------+-------------+
| 3 | Lorem Ipsum | lorem-ipsum | 2016-06-01 14:34:36 | publish |
| 1 | Hello world! | hello-world | 2016-06-01 14:31:12 | publish |
+----+--------------+-------------+---------------------+-------------+
# List given post by a specific author
$ wp post list --author=2
+----+-------------------+-------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+----+-------------------+-------------------+---------------------+-------------+
| 14 | New documentation | new-documentation | 2021-06-18 21:05:11 | publish |
+----+-------------------+-------------------+---------------------+-------------+
WordPress帖子元数据
添加、更新、删除和列出帖子自定义字段。
wp post meta
示例
# Set post meta
$ wp post meta set 123 _wp_page_template about.php
Success: Updated custom field '_wp_page_template'.
# Get post meta
$ wp post meta get 123 _wp_page_template
about.php
# Update post meta
$ wp post meta update 123 _wp_page_template contact.php
Success: Updated custom field '_wp_page_template'.
# Delete post meta
$ wp post meta delete 123 _wp_page_template
Success: Deleted custom field.
WordPress帖子元数据添加
添加元字段。
wp post meta add <id> <key> [<value>] [--format=<format>]
选项
<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
---
WordPress帖子元数据清理重复项
清理帖子上的重复元数据值。
wp post meta clean-duplicates <id> <key>
选项
<id>
ID of the post to clean.
<key>
Meta key to clean up.
示例
# Delete duplicate post meta.
wp post meta clean-duplicates 1234 enclosure
Success: Cleaned up duplicate 'enclosure' meta values.
WordPress帖子元数据删除
删除元字段。
wp post meta delete <id> [<key>] [<value>] [--all]
选项
<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.
WordPress帖子元数据获取
获取元字段值。
wp post meta get <id> <key> [--format=<format>]
选项
<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
---
WordPress帖子元数据列表
列出与对象关联的所有元数据。
wp post meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<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.
WordPress帖子元数据修补
更新元字段的嵌套值。
wp post meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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
---
WordPress帖子元数据提取
从元字段获取嵌套值。
wp post meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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
WordPress帖子元数据更新
更新元字段。
wp post meta update <id> <key> [<value>] [--format=<format>]
选项
<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
---
WordPress帖子术语
添加、更新、删除和列出帖子术语。
wp post term
示例
# Set category post term `test` to the post ID 123
$ wp post term set 123 test category
Success: Set term.
# Set category post terms `test` and `apple` to the post ID 123
$ wp post term set 123 test apple category
Success: Set terms.
# List category post terms for the post ID 123
$ wp post term list 123 category --fields=term_id,slug
+---------+-------+
| term_id | slug |
+---------+-------+
| 2 | apple |
| 3 | test |
+----------+------+
# Remove category post terms `test` and `apple` for the post ID 123
$ wp post term remove 123 category test apple
Success: Removed terms.
WordPress帖子术语添加
将术语添加到对象中。
wp post term add <id> <taxonomy> <term>... [--by=<field>]
将术语追加到对象上现有的术语集中。
选项
<id>
The ID of the object.
<taxonomy>
The name of the taxonomy type to be added.
<term>...
The slug of the term or terms to be added.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
WordPress帖子术语列表
列出与对象关联的所有术语。
wp post term list <id> <taxonomy>... [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<id>
ID for the object.
<taxonomy>...
One or more taxonomies to list.
[--field=<field>]
Prints the value of a single field for each term.
[--fields=<fields>]
Limit the output to specific row fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
- count
- ids
---
可用字段
以下字段将为每个术语默认显示
- term_id
- name
- slug
- taxonomy
以下字段为可选字段
- term_taxonomy_id
- description
- term_group
- parent
- count
WordPress帖子术语删除
从对象中删除术语。
wp post term remove <id> <taxonomy> [<term>...] [--by=<field>] [--all]
选项
<id>
The ID of the object.
<taxonomy>
The name of the term's taxonomy.
[<term>...]
The slug of the term or terms to be removed from the object.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
[--all]
Remove all terms from the object.
WordPress帖子术语设置
设置对象术语。
wp post term set <id> <taxonomy> <term>... [--by=<field>]
替换对象上的现有术语。
选项
<id>
The ID of the object.
<taxonomy>
The name of the taxonomy type to be updated.
<term>...
The slug of the term or terms to be updated.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
WordPress帖子更新
更新一个或多个现有帖子。
wp post update <id>... [--post_author=<post_author>] [--post_date=<post_date>] [--post_date_gmt=<post_date_gmt>] [--post_content=<post_content>] [--post_content_filtered=<post_content_filtered>] [--post_title=<post_title>] [--post_excerpt=<post_excerpt>] [--post_status=<post_status>] [--post_type=<post_type>] [--comment_status=<comment_status>] [--ping_status=<ping_status>] [--post_password=<post_password>] [--post_name=<post_name>] [--to_ping=<to_ping>] [--pinged=<pinged>] [--post_modified=<post_modified>] [--post_modified_gmt=<post_modified_gmt>] [--post_parent=<post_parent>] [--menu_order=<menu_order>] [--post_mime_type=<post_mime_type>] [--guid=<guid>] [--post_category=<post_category>] [--tags_input=<tags_input>] [--tax_input=<tax_input>] [--meta_input=<meta_input>] [<file>] --<field>=<value> [--defer-term-counting]
选项
<id>...
One or more IDs of posts to update.
[--post_author=<post_author>]
The ID of the user who added the post. Default is the current user ID.
[--post_date=<post_date>]
The date of the post. Default is the current time.
[--post_date_gmt=<post_date_gmt>]
The date of the post in the GMT timezone. Default is the value of $post_date.
[--post_content=<post_content>]
The post content. Default empty.
[--post_content_filtered=<post_content_filtered>]
The filtered post content. Default empty.
[--post_title=<post_title>]
The post title. Default empty.
[--post_excerpt=<post_excerpt>]
The post excerpt. Default empty.
[--post_status=<post_status>]
The post status. Default 'draft'.
[--post_type=<post_type>]
The post type. Default 'post'.
[--comment_status=<comment_status>]
Whether the post can accept comments. Accepts 'open' or 'closed'. Default is the value of 'default_comment_status' option.
[--ping_status=<ping_status>]
Whether the post can accept pings. Accepts 'open' or 'closed'. Default is the value of 'default_ping_status' option.
[--post_password=<post_password>]
The password to access the post. Default empty.
[--post_name=<post_name>]
The post name. Default is the sanitized post title when creating a new post.
[--to_ping=<to_ping>]
Space or carriage return-separated list of URLs to ping. Default empty.
[--pinged=<pinged>]
Space or carriage return-separated list of URLs that have been pinged. Default empty.
[--post_modified=<post_modified>]
The date when the post was last modified. Default is the current time.
[--post_modified_gmt=<post_modified_gmt>]
The date when the post was last modified in the GMT timezone. Default is the current time.
[--post_parent=<post_parent>]
Set this for the post it belongs to, if any. Default 0.
[--menu_order=<menu_order>]
The order the post should be displayed in. Default 0.
[--post_mime_type=<post_mime_type>]
The mime type of the post. Default empty.
[--guid=<guid>]
Global Unique ID for referencing the post. Default empty.
[--post_category=<post_category>]
Array of category names, slugs, or IDs. Defaults to value of the 'default_category' option.
[--tags_input=<tags_input>]
Array of tag names, slugs, or IDs. Default empty.
[--tax_input=<tax_input>]
Array of taxonomy terms keyed by their taxonomy name. Default empty.
[--meta_input=<meta_input>]
Array in JSON format of post meta values keyed by their post meta key. Default empty.
[<file>]
Read post content from <file>. If this value is present, the
`--post_content` argument will be ignored.
将 -
作为文件名传递会导致从 STDIN 读取文章内容。
--<field>=<value>
One or more fields to update. See wp_insert_post().
[--defer-term-counting]
Recalculate term count in batch, for a performance boost.
示例
$ wp post update 123 --post_name=something --post_status=draft
Success: Updated post 123.
# Update a post with multiple meta values.
$ wp post update 123 --meta_input='{"key1":"value1","key2":"value2"}'
Success: Updated post 123.
# Update multiple posts at once.
$ wp post update 123 456 --post_author=789
Success: Updated post 123.
Success: Updated post 456.
# Update all posts of a given post type at once.
$ wp post update $(wp post list --post_type=page --format=ids) --post_author=123
Success: Updated post 123.
Success: Updated post 456.
WordPress帖子URL-to-ID
获取给定URL的帖子ID。
wp post url-to-id <url>
选项
<url>
The URL of the post to get.
示例
# Get post ID by URL
$ wp post url-to-id https://example.com/?p=1
1
WordPress帖子类型
检索网站已注册帖子类型的详细信息。
wp post-type
获取WordPress内置和网站的自定义帖子类型信息。
示例
# Get details about a post type
$ wp post-type get page --fields=name,label,hierarchical --format=json
{"name":"page","label":"Pages","hierarchical":true}
# List post types with 'post' capability type
$ wp post-type list --capability_type=post --fields=name,public
+---------------+--------+
| name | public |
+---------------+--------+
| post | 1 |
| attachment | 1 |
| revision | |
| nav_menu_item | |
+---------------+--------+
WordPress帖子类型获取
获取已注册帖子类型的详细信息。
wp post-type get <post-type> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<post-type>
Post type slug
[--field=<field>]
Instead of returning the whole taxonomy, 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
---
可用字段
以下字段将为指定帖子类型默认显示
- name
- 标签
- description
- 分层
- 公开
- 能力类型
- 标签
- 权限
- 支持
以下字段为可选字段
- count
示例
# Get details about the 'page' post type.
$ wp post-type get page --fields=name,label,hierarchical --format=json
{"name":"page","label":"Pages","hierarchical":true}
WordPress帖子类型列表
列出已注册的帖子类型。
wp post-type list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
[--<field>=<value>]
Filter by one or more fields (see get_post_types() first parameter for a list of available fields).
[--field=<field>]
Prints the value of a single field for each post type.
[--fields=<fields>]
Limit the output to specific post type fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- count
- yaml
---
可用字段
以下字段将为每个帖子类型默认显示
- name
- 标签
- description
- 分层
- 公开
- 能力类型
以下字段为可选字段
- count
示例
# List registered post types
$ wp post-type list --format=csv
name,label,description,hierarchical,public,capability_type
post,Posts,,,1,post
page,Pages,,1,1,page
attachment,Media,,,1,post
revision,Revisions,,,,post
nav_menu_item,"Navigation Menu Items",,,,post
# List post types with 'post' capability type
$ wp post-type list --capability_type=post --fields=name,public
+---------------+--------+
| name | public |
+---------------+--------+
| post | 1 |
| attachment | 1 |
| revision | |
| nav_menu_item | |
+---------------+--------+
博客_id
最后更新
wp site
示例
# Create site
$ wp site create --slug=example
Success: Site 3 created: www.example.com/example/
# Output a simple list of site URLs
$ wp site list --field=url
http://www.example.com/
http://www.example.com/subdir/
# Delete site
$ wp site delete 123
Are you sure you want to delete the 'http://www.example.com/example' site? [y/n] y
Success: The site at 'http://www.example.com/example' was deleted.
注册
网站_id
wp site activate [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to activate. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be activated. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site activate 123
Success: Site 123 activated.
$ wp site activate --slug=demo
Success: Site 123 marked as activated.
域名
路径
wp site archive [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to archive. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to archive. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site archive 123
Success: Site 123 archived.
$ wp site archive --slug=demo
Success: Site 123 archived.
存档
成熟
wp site create --slug=<slug> [--title=<title>] [--email=<email>] [--network_id=<network-id>] [--private] [--porcelain]
选项
--slug=<slug>
Path for the new site. Subdomain on subdomain installs, directory on subdirectory installs.
[--title=<title>]
Title of the new site. Default: prettified slug.
[--email=<email>]
Email for admin user. User will be created if none exists. Assignment to super admin if not included.
[--network_id=<network-id>]
Network to associate new site with. Defaults to current network (typically 1).
[--private]
If set, the new site will be non-public (not indexed)
[--porcelain]
If set, only the site id will be output on success.
示例
$ wp site create --slug=example
Success: Site 3 created: http://www.example.com/example/
垃圾邮件
删除
wp site generate [--count=<number>] [--slug=<slug>] [--email=<email>] [--network_id=<network-id>] [--private] [--format=<format>]
语言_id
选项
[--count=<number>]
How many sites to generates?
---
default: 100
---
[--slug=<slug>]
Path for the new site. Subdomain on subdomain installs, directory on subdirectory installs.
[--email=<email>]
Email for admin user. User will be created if none exists. Assignment to super admin if not included.
[--network_id=<network-id>]
Network to associate new site with. Defaults to current network (typically 1).
[--private]
If set, the new site will be non-public (not indexed)
[--format=<format>]
Render output in a particular format.
---
default: progress
options:
- progress
- ids
---
示例
WordPress网站
创建、删除、清空、审核和列出多站安装中的一个或多个网站。
WordPress网站激活
激活一个或多个网站。
wp site deactivate [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to deactivate. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be deactivated. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site deactivate 123
Success: Site 123 deactivated.
$ wp site deactivate --slug=demo
Success: Site 123 deactivated.
WordPress网站存档
存档一个或多个网站。
wp site delete [<site-id>] [--slug=<slug>] [--yes] [--keep-tables]
选项
[<site-id>]
The id of the site to delete. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be deleted. Subdomain on subdomain installs, directory on subdirectory installs.
[--yes]
Answer yes to the confirmation message.
[--keep-tables]
Delete the blog from the list, but don't drop its tables.
示例
$ wp site delete 123
Are you sure you want to delete the http://www.example.com/example site? [y/n] y
Success: The site at 'http://www.example.com/example' was deleted.
WordPress网站创建
在多站安装中创建一个网站。
wp site empty [--uploads] [--yes]
WordPress网站生成
生成一些网站。
创建指定数量的新网站。
WP_CLI::add_hook( 'after_invoke:site empty', function(){
global $wpdb;
foreach( array( 'p2p', 'p2pmeta' ) as $table ) {
$table = $wpdb->$table;
$wpdb->query( "TRUNCATE $table" );
}
});
选项
[--uploads]
Also delete *all* files in the site's uploads directory.
[--yes]
Proceed to empty the site without a confirmation prompt.
示例
$ wp site empty
Are you sure you want to empty the site at http://www.example.com of all posts, links, comments, and terms? [y/n] y
Success: The site at 'http://www.example.com' was emptied.
生成10个网站。
WordPress网站生成 --count=10 生成网站 100% [================================================] 0:01 / 0:04
wp site list [--network=<id>] [--<field>=<value>] [--site__in=<value>] [--site_user=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
[--network=<id>]
The network to which the sites belong.
[--<field>=<value>]
Filter by one or more fields (see "Available Fields" section). However,
'url' isn't an available filter, as it comes from 'home' in wp_options.
[--site__in=<value>]
Only list the sites with these blog_id values (comma-separated).
[--site_user=<value>]
Only list the sites with this user.
[--field=<field>]
Prints the value of a single field for each site.
[--fields=<fields>]
Comma-separated list of fields to show.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- count
- ids
- json
- yaml
---
可用字段
WordPress网站停用
- 停用一个或多个网站。
- url
- WordPress网站删除
- 在多站安装中删除一个网站。
以下字段为可选字段
- WordPress网站清空
- 清空网站的内容(帖子、评论、术语和元数据)。
- 截断帖子、评论和术语表以清空网站内容。不影响网站配置(选项)或用户。
- 公开
- 如果运行持久性对象缓存,请在清空网站后确保刷新缓存,否则缓存值将无效。
- 要清空自定义数据库表,需要挂钩到命令执行
- WordPress网站列表
- 列出多站安装中的所有网站。
- 以下字段将为每个网站默认显示
示例
# Output a simple list of site URLs
$ wp site list --field=url
http://www.example.com/
http://www.example.com/subdir/
博客_id
最后更新
wp site mature [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to set as mature. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be set as mature. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site mature 123
Success: Site 123 marked as mature.
$ wp site mature --slug=demo
Success: Site 123 marked as mature.
注册
网站_id
wp site meta
示例
# Set site meta
$ wp site meta set 123 bio "Mary is a WordPress developer."
Success: Updated custom field 'bio'.
# Get site meta
$ wp site meta get 123 bio
Mary is a WordPress developer.
# Update site meta
$ wp site meta update 123 bio "Mary is an awesome WordPress developer."
Success: Updated custom field 'bio'.
# Delete site meta
$ wp site meta delete 123 bio
Success: Deleted custom field.
域名
添加元字段。
wp site meta add <id> <key> [<value>] [--format=<format>]
选项
<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 site meta delete <id> [<key>] [<value>] [--all]
选项
<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 site meta get <id> <key> [--format=<format>]
选项
<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 site meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<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 site meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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 site meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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
语言_id
更新元字段。
wp site meta update <id> <key> [<value>] [--format=<format>]
选项
<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
---
WordPress网站成熟
将一个或多个网站设置为成熟。
wp site option
示例
# Get site registration
$ wp site option get registration
none
# Add site option
$ wp site option add my_option foobar
Success: Added 'my_option' site option.
# Update site option
$ wp site option update my_option '{"foo": "bar"}' --format=json
Success: Updated 'my_option' site option.
# Delete site option
$ wp site option delete my_option
Success: Deleted 'my_option' site option.
WordPress网站元数据
添加、更新、删除和列出网站自定义字段。
wp site private [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to set as private. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be set as private. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site private 123
Success: Site 123 marked as private.
$ wp site private --slug=demo
Success: Site 123 marked as private.
WordPress网站元数据添加
WordPress网站元数据删除
wp site public [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to set as public. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be set as public. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site public 123
Success: Site 123 marked as public.
$ wp site public --slug=demo
Success: Site 123 marked as public.
WordPress网站元数据获取
将一个或多个站点标记为垃圾邮件。
wp site spam [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to be marked as spam. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be marked as spam. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site spam 123
Success: Site 123 marked as spam.
wp site unarchive
恢复一个或多个站点的存档。
wp site unarchive [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to unarchive. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to unarchive. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site unarchive 123
Success: Site 123 unarchived.
$ wp site unarchive --slug=demo
Success: Site 123 unarchived.
wp site unmature
将一个或多个站点设置为不成熟。
wp site unmature [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to set as unmature. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be set as unmature. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site unmature 123
Success: Site 123 marked as unmature.
$ wp site unmature --slug=demo
Success: Site 123 marked as unmature.
wp site unspam
从垃圾邮件中移除一个或多个站点。
wp site unspam [<id>...] [--slug=<slug>]
选项
[<id>...]
One or more IDs of sites to remove from spam. If not provided, you must set the --slug parameter.
[--slug=<slug>]
Path of the site to be removed from spam. Subdomain on subdomain installs, directory on subdirectory installs.
示例
$ wp site unspam 123
Success: Site 123 removed from spam.
wp taxonomy
检索有关已注册分类法的信息。
wp taxonomy
示例
# List all taxonomies with 'post' object type.
$ wp taxonomy list --object_type=post --fields=name,public
+-------------+--------+
| name | public |
+-------------+--------+
| category | 1 |
| post_tag | 1 |
| post_format | 1 |
+-------------+--------+
# Get capabilities of 'post_tag' taxonomy.
$ wp taxonomy get post_tag --field=cap
{"manage_terms":"manage_categories","edit_terms":"manage_categories","delete_terms":"manage_categories","assign_terms":"edit_posts"}
wp taxonomy get
获取有关已注册分类法的详细信息。
wp taxonomy get <taxonomy> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<taxonomy>
Taxonomy slug.
[--field=<field>]
Instead of returning the whole taxonomy, 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
---
可用字段
以下字段将默认显示为指定分类的
- name
- 标签
- description
- object_type
- show_tagcloud
- 分层
- 公开
- 标签
- 权限
以下字段为可选字段
- count
示例
# Get details of `category` taxonomy.
$ wp taxonomy get category --fields=name,label,object_type
+-------------+------------+
| Field | Value |
+-------------+------------+
| name | category |
| label | Categories |
| object_type | ["post"] |
+-------------+------------+
# Get capabilities of 'post_tag' taxonomy.
$ wp taxonomy get post_tag --field=cap
{"manage_terms":"manage_categories","edit_terms":"manage_categories","delete_terms":"manage_categories","assign_terms":"edit_posts"}
wp taxonomy list
列出已注册的分类法。
wp taxonomy list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
[--<field>=<value>]
Filter by one or more fields (see get_taxonomies() first parameter for a list of available fields).
[--field=<field>]
Prints the value of a single field for each taxonomy.
[--fields=<fields>]
Limit the output to specific taxonomy fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- count
- yaml
---
可用字段
以下字段将为每个术语默认显示
- name
- 标签
- description
- object_type
- show_tagcloud
- 分层
- 公开
以下字段为可选字段
- count
示例
# List all taxonomies.
$ wp taxonomy list --format=csv
name,label,description,object_type,show_tagcloud,hierarchical,public
category,Categories,,post,1,1,1
post_tag,Tags,,post,1,,1
nav_menu,"Navigation Menus",,nav_menu_item,,,
link_category,"Link Categories",,link,1,,
post_format,Format,,post,,,1
# List all taxonomies with 'post' object type.
$ wp taxonomy list --object_type=post --fields=name,public
+-------------+--------+
| name | public |
+-------------+--------+
| category | 1 |
| post_tag | 1 |
| post_format | 1 |
+-------------+--------+
wp term
管理分类法术语和术语元数据,包括创建、删除和列出命令。
wp term
有关分类法和它们的术语的参考。
示例
# Create a new term.
$ wp term create category Apple --description="A type of fruit"
Success: Created category 199.
# Get details about a term.
$ wp term get category 199 --format=json --fields=term_id,name,slug,count
{"term_id":199,"name":"Apple","slug":"apple","count":1}
# Update an existing term.
$ wp term update category 15 --name=Apple
Success: Term updated.
# Get the term's URL.
$ wp term list post_tag --include=123 --field=url
http://example.com/tag/tips-and-tricks
# Delete post category
$ wp term delete category 15
Success: Deleted category 15.
# Recount posts assigned to each categories and tags
$ wp term recount category post_tag
Success: Updated category term count
Success: Updated post_tag term count
wp term create
创建一个新的术语。
wp term create <taxonomy> <term> [--slug=<slug>] [--description=<description>] [--parent=<term-id>] [--porcelain]
选项
<taxonomy>
Taxonomy for the new term.
<term>
A name for the new term.
[--slug=<slug>]
A unique slug for the new term. Defaults to sanitized version of name.
[--description=<description>]
A description for the new term.
[--parent=<term-id>]
A parent for the new term.
[--porcelain]
Output just the new term id.
示例
# Create a new category "Apple" with a description.
$ wp term create category Apple --description="A type of fruit"
Success: Created category 199.
wp term delete
删除一个现有的术语。
wp term delete <taxonomy> <term>... [--by=<field>]
如果术语不存在或删除过程中出现问题时,将返回错误。
选项
<taxonomy>
Taxonomy of the term to delete.
<term>...
One or more IDs or slugs of terms to delete.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: id
options:
- slug
- id
---
示例
# Delete post category by id
$ wp term delete category 15
Deleted category 15.
Success: Deleted 1 of 1 terms.
# Delete post category by slug
$ wp term delete category apple --by=slug
Deleted category 15.
Success: Deleted 1 of 1 terms.
# Delete all post tags
$ wp term list post_tag --field=term_id | xargs wp term delete post_tag
Deleted post_tag 159.
Deleted post_tag 160.
Deleted post_tag 161.
Success: Deleted 3 of 3 terms.
wp term generate
生成一些术语。
wp term generate <taxonomy> [--count=<number>] [--max_depth=<number>] [--format=<format>]
使用示例数据创建指定数量的新术语。
选项
<taxonomy>
The taxonomy for the generated terms.
[--count=<number>]
How many terms to generate?
---
default: 100
---
[--max_depth=<number>]
Generate child terms down to a certain depth.
---
default: 1
---
[--format=<format>]
Render output in a particular format.
---
default: progress
options:
- progress
- ids
---
示例
# Generate post categories.
$ wp term generate category --count=10
Generating terms 100% [=========] 0:02 / 0:02
# Add meta to every generated term.
$ wp term generate category --format=ids --count=3 | xargs -d ' ' -I % wp term meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.
wp term get
获取有关术语的详细信息。
wp term get <taxonomy> <term> [--by=<field>] [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<taxonomy>
Taxonomy of the term to get
<term>
ID or slug of the term to get
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: id
options:
- slug
- id
---
[--field=<field>]
Instead of returning the whole term, 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
---
示例
# Get details about a category with id 199.
$ wp term get category 199 --format=json
{"term_id":199,"name":"Apple","slug":"apple","term_group":0,"term_taxonomy_id":199,"taxonomy":"category","description":"A type of fruit","parent":0,"count":0,"filter":"raw"}
# Get details about a category with slug apple.
$ wp term get category apple --by=slug --format=json
{"term_id":199,"name":"Apple","slug":"apple","term_group":0,"term_taxonomy_id":199,"taxonomy":"category","description":"A type of fruit","parent":0,"count":0,"filter":"raw"}
wp term list
列出分类法中的术语。
wp term list <taxonomy>... [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<taxonomy>...
List terms of one or more taxonomies
[--<field>=<value>]
Filter by one or more fields (see get_terms() $args parameter for a list of fields).
[--field=<field>]
Prints the value of a single field for each term.
[--fields=<fields>]
Limit the output to specific object fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- ids
- json
- count
- yaml
---
可用字段
以下字段将为每个术语默认显示
- term_id
- term_taxonomy_id
- name
- slug
- description
- parent
- count
以下字段为可选字段
- url
示例
# List post categories
$ wp term list category --format=csv
term_id,term_taxonomy_id,name,slug,description,parent,count
2,2,aciform,aciform,,0,1
3,3,antiquarianism,antiquarianism,,0,1
4,4,arrangement,arrangement,,0,1
5,5,asmodeus,asmodeus,,0,1
# List post tags
$ wp term list post_tag --fields=name,slug
+-----------+-------------+
| name | slug |
+-----------+-------------+
| 8BIT | 8bit |
| alignment | alignment-2 |
| Articles | articles |
| aside | aside |
+-----------+-------------+
wp term meta
添加、更新、删除和列出术语自定义字段。
wp term meta
示例
# Set term meta
$ wp term meta set 123 bio "Mary is a WordPress developer."
Success: Updated custom field 'bio'.
# Get term meta
$ wp term meta get 123 bio
Mary is a WordPress developer.
# Update term meta
$ wp term meta update 123 bio "Mary is an awesome WordPress developer."
Success: Updated custom field 'bio'.
# Delete term meta
$ wp term meta delete 123 bio
Success: Deleted custom field.
wp term meta add
添加元字段。
wp term meta add <id> <key> [<value>] [--format=<format>]
选项
<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 term meta delete
删除元字段。
wp term meta delete <id> [<key>] [<value>] [--all]
选项
<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 term meta get
获取元字段值。
wp term meta get <id> <key> [--format=<format>]
选项
<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 term meta list
列出与对象关联的所有元数据。
wp term meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<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 term meta patch
更新元字段的嵌套值。
wp term meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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 term meta pluck
从元字段获取嵌套值。
wp term meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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 term meta update
更新元字段。
wp term meta update <id> <key> [<value>] [--format=<format>]
选项
<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 term recount
重新计算分配给每个术语的帖子的数量。
wp term recount <taxonomy>...
在数据库中对分配给帖子的术语进行手动更新时,与术语关联的帖子的数量可能与实际帖子的数量不一致。
此命令对分类法的术语运行wp_update_term_count(),以将计数恢复到正确值。
选项
<taxonomy>...
One or more taxonomies to recalculate.
示例
# Recount posts assigned to each categories and tags
$ wp term recount category post_tag
Success: Updated category term count.
Success: Updated post_tag term count.
# Recount all listed taxonomies
$ wp taxonomy list --field=name | xargs wp term recount
Success: Updated category term count.
Success: Updated post_tag term count.
Success: Updated nav_menu term count.
Success: Updated link_category term count.
Success: Updated post_format term count.
wp term update
更新一个现有的术语。
wp term update <taxonomy> <term> [--by=<field>] [--name=<name>] [--slug=<slug>] [--description=<description>] [--parent=<term-id>]
选项
<taxonomy>
Taxonomy of the term to update.
<term>
ID or slug for the term to update.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: id
options:
- slug
- id
---
[--name=<name>]
A new name for the term.
[--slug=<slug>]
A new slug for the term.
[--description=<description>]
A new description for the term.
[--parent=<term-id>]
A new parent for the term.
示例
# Change category with id 15 to use the name "Apple"
$ wp term update category 15 --name=Apple
Success: Term updated.
# Change category with slug apple to use the name "Apple"
$ wp term update category apple --by=slug --name=Apple
Success: Term updated.
wp user
管理用户及其角色、能力和元数据。
wp user
示例
# List user IDs
$ wp user list --field=ID
1
# Create a new user.
$ wp user create bob [email protected] --role=author
Success: Created user 3.
Password: k9**&I4vNH(&
# Update an existing user.
$ wp user update 123 --display_name=Mary --user_pass=marypass
Success: Updated user 123.
# Delete user 123 and reassign posts to user 567
$ wp user delete 123 --reassign=567
Success: Removed user 123 from http://example.com.
wp user add-cap
向用户添加能力。
wp user add-cap <user> <cap>
选项
<user>
User ID, user email, or user login.
<cap>
The capability to add.
示例
# Add a capability for a user
$ wp user add-cap john create_premium_item
Success: Added 'create_premium_item' capability for john (16).
# Add a capability for a user
$ wp user add-cap 15 edit_product
Success: Added 'edit_product' capability for johndoe (15).
wp user add-role
为用户添加角色。
wp user add-role <user> [<role>...]
选项
<user>
User ID, user email, or user login.
[<role>...]
Add the specified role(s) to the user.
示例
$ wp user add-role 12 author
Success: Added 'author' role for johndoe (12).
$ wp user add-role 12 author editor
Success: Added 'author', 'editor' roles for johndoe (12).
wp user application-password
创建、更新、删除、列出和检索应用程序密码。
wp user application-password
示例
# List user application passwords and only show app name and password hash
$ wp user application-password list 123 --fields=name,password
+--------+------------------------------------+
| name | password |
+--------+------------------------------------+
| myapp | $P$BVGeou1CUot114YohIemgpwxQCzb8O/ |
+--------+------------------------------------+
# Get a specific application password and only show app name and created timestamp
$ wp user application-password get 123 6633824d-c1d7-4f79-9dd5-4586f734d69e --fields=name,created
+--------+------------+
| name | created |
+--------+------------+
| myapp | 1638395611 |
+--------+------------+
# Create user application password
$ wp user application-password create 123 myapp
Success: Created application password.
Password: ZG1bxdxdzjTwhsY8vK8l1C65
# Only print the password without any chrome
$ wp user application-password create 123 myapp --porcelain
ZG1bxdxdzjTwhsY8vK8l1C65
# Update an existing application password
$ wp user application-password update 123 6633824d-c1d7-4f79-9dd5-4586f734d69e --name=newappname
Success: Updated application password.
# Delete an existing application password
$ wp user application-password delete 123 6633824d-c1d7-4f79-9dd5-4586f734d69e
Success: Deleted 1 of 1 application password.
# Check if an application password for a given application exists
$ wp user application-password exists 123 myapp
$ echo $?
1
# Bash script for checking whether an application password exists and creating one if not
if ! wp user application-password exists 123 myapp; then
PASSWORD=$(wp user application-password create 123 myapp --porcelain)
fi
wp user application-password create
创建一个新的应用程序密码。
wp user application-password create <user> <app-name> [--app-id=<app-id>] [--porcelain]
选项
<user>
The user login, user email, or user ID of the user to create a new application password for.
<app-name>
Unique name of the application to create an application password for.
[--app-id=<app-id>]
Application ID to attribute to the application password.
[--porcelain]
Output just the new password.
示例
# Create user application password
$ wp user application-password create 123 myapp
Success: Created application password.
Password: ZG1bxdxdzjTwhsY8vK8l1C65
# Only print the password without any chrome
$ wp user application-password create 123 myapp --porcelain
ZG1bxdxdzjTwhsY8vK8l1C65
# Create user application with a custom application ID for internal tracking
$ wp user application-password create 123 myapp --app-id=42 --porcelain
ZG1bxdxdzjTwhsY8vK8l1C65
wp user application-password delete
删除一个现有的应用程序密码。
wp user application-password delete <user> [<uuid>...] [--all]
选项
<user>
The user login, user email, or user ID of the user to delete the application password for.
[<uuid>...]
Comma-separated list of UUIDs of the application passwords to delete.
[--all]
Delete all of the user's application password.
示例
# Delete an existing application password
$ wp user application-password delete 123 6633824d-c1d7-4f79-9dd5-4586f734d69e
Success: Deleted 1 of 1 application password.
# Delete all of the user's application passwords
$ wp user application-password delete 123 --all
Success: Deleted all application passwords.
wp user application-password exists
检查是否存在特定应用程序的应用程序密码。
wp user application-password exists <user> <app-name>
选项
<user>
The user login, user email, or user ID of the user to check the existence of an application password for.
<app-name>
Name of the application to check the existence of an application password for.
示例
# Check if an application password for a given application exists
$ wp user application-password exists 123 myapp
$ echo $?
1
# Bash script for checking whether an application password exists and creating one if not
if ! wp user application-password exists 123 myapp; then
PASSWORD=$(wp user application-password create 123 myapp --porcelain)
fi
wp user application-password get
获取特定应用程序密码。
wp user application-password get <user> <uuid> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<user>
The user login, user email, or user ID of the user to get the application password for.
<uuid>
The universally unique ID of the application password.
[--field=<field>]
Prints the value of a single field for the application password.
[--fields=<fields>]
Limit the output to specific fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---
示例
# Get a specific application password and only show app name and created timestamp
$ wp user application-password get 123 6633824d-c1d7-4f79-9dd5-4586f734d69e --fields=name,created
+--------+------------+
| name | created |
+--------+------------+
| myapp | 1638395611 |
+--------+------------+
wp user application-password list
列出与用户关联的所有应用程序密码。
wp user application-password list <user> [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>]
选项
<user>
The user login, user email, or user ID of the user to get application passwords for.
[--<field>=<value>]
Filter the list by a specific field.
[--field=<field>]
Prints the value of a single field for each application password.
[--fields=<fields>]
Limit the output to specific fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- count
- yaml
- ids
---
[--orderby=<fields>]
Set orderby which field.
---
default: created
options:
- uuid
- app_id
- name
- password
- created
- last_used
- last_ip
---
[--order=<order>]
Set ascending or descending order.
---
default: desc
options:
- asc
- desc
---
示例
# List user application passwords and only show app name and password hash
$ wp user application-password list 123 --fields=name,password
+--------+------------------------------------+
| name | password |
+--------+------------------------------------+
| myapp | $P$BVGeou1CUot114YohIemgpwxQCzb8O/ |
+--------+------------------------------------+
wp user application-password record-usage
记录应用程序密码的使用情况。
wp user application-password record-usage <user> <uuid>
选项
<user>
The user login, user email, or user ID of the user to update the application password for.
<uuid>
The universally unique ID of the application password.
示例
# Record usage of an application password
$ wp user application-password record-usage 123 6633824d-c1d7-4f79-9dd5-4586f734d69e
Success: Recorded application password usage.
wp user application-password update
更新现有的应用程序密码。
wp user application-password update <user> <uuid> [--<field>=<value>]
选项
<user>
The user login, user email, or user ID of the user to update the application password for.
<uuid>
The universally unique ID of the application password.
[--<field>=<value>]
Update the <field> with a new <value>. Currently supported fields: name.
示例
# Update an existing application password
$ wp user application-password update 123 6633824d-c1d7-4f79-9dd5-4586f734d69e --name=newappname
Success: Updated application password.
wp user create
创建一个新用户。
wp user create <user-login> <user-email> [--role=<role>] [--user_pass=<password>] [--user_registered=<yyyy-mm-dd-hh-ii-ss>] [--display_name=<name>] [--user_nicename=<nice_name>] [--user_url=<url>] [--nickname=<nickname>] [--first_name=<first_name>] [--last_name=<last_name>] [--description=<description>] [--rich_editing=<rich_editing>] [--send-email] [--porcelain]
选项
<user-login>
The login of the user to create.
<user-email>
The email address of the user to create.
[--role=<role>]
The role of the user to create. Default: default role. Possible values
include 'administrator', 'editor', 'author', 'contributor', 'subscriber'.
[--user_pass=<password>]
The user password. Default: randomly generated.
[--user_registered=<yyyy-mm-dd-hh-ii-ss>]
The date the user registered. Default: current date.
[--display_name=<name>]
The display name.
[--user_nicename=<nice_name>]
A string that contains a URL-friendly name for the user. The default is the user's username.
[--user_url=<url>]
A string containing the user's URL for the user's web site.
[--nickname=<nickname>]
The user's nickname, defaults to the user's username.
[--first_name=<first_name>]
The user's first name.
[--last_name=<last_name>]
The user's last name.
[--description=<description>]
A string containing content about the user.
[--rich_editing=<rich_editing>]
A string for whether to enable the rich editor or not. False if not empty.
[--send-email]
Send an email to the user with their new account details.
[--porcelain]
Output just the new user id.
示例
# Create user
$ wp user create bob [email protected] --role=author
Success: Created user 3.
Password: k9**&I4vNH(&
# Create user without showing password upon success
$ wp user create ann [email protected] --porcelain
4
wp user delete
从当前站点删除一个或多个用户。
wp user delete <user>... [--network] [--reassign=<user-id>] [--yes]
在多站点中,wp user delete
仅从当前站点删除用户。包含--network
以同时从数据库中删除用户,但请确保在删除用户之前重新分配他们的帖子。
选项
<user>...
The user login, user email, or user ID of the user(s) to delete.
[--network]
On multisite, delete the user from the entire network.
[--reassign=<user-id>]
User ID to reassign the posts to.
[--yes]
Answer yes to any confirmation prompts.
示例
# Delete user 123 and reassign posts to user 567
$ wp user delete 123 --reassign=567
Success: Removed user 123 from http://example.com.
# Delete all contributors and reassign their posts to user 2
$ wp user delete $(wp user list --role=contributor --field=ID) --reassign=2
Success: Removed user 813 from http://example.com.
Success: Removed user 578 from http://example.com.
# Delete all contributors in batches of 100 (avoid error: argument list too long: wp)
$ wp user delete $(wp user list --role=contributor --field=ID | head -n 100)
wp user exists
验证用户是否存在。
wp user exists <id>
如果用户存在,则显示成功消息。
选项
<id>
The ID of the user to check.
示例
# The user exists.
$ wp user exists 1337
Success: User with ID 1337 exists.
$ echo $?
0
# The user does not exist.
$ wp user exists 10000
$ echo $?
1
wp用户生成
生成一些用户。
wp user generate [--count=<number>] [--role=<role>] [--format=<format>]
使用虚拟数据创建指定数量的新用户。
选项
[--count=<number>]
How many users to generate?
---
default: 100
---
[--role=<role>]
The role of the generated users. Default: default role from WP
[--format=<format>]
Render output in a particular format.
---
default: progress
options:
- progress
- ids
---
示例
# Add meta to every generated users.
$ wp user generate --format=ids --count=3 | xargs -d ' ' -I % wp user meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.
wp用户获取
获取关于用户的信息。
wp user get <user> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<user>
User ID, user email, or user login.
[--field=<field>]
Instead of returning the whole user, returns the value of a single field.
[--fields=<fields>]
Get a specific subset of the user's fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---
示例
# Get user
$ wp user get 12 --field=login
supervisor
# Get user and export to JSON file
$ wp user get bob --format=json > bob.json
wp用户导入-csv
从CSV文件导入用户。
wp user import-csv <file> [--send-email] [--skip-update]
如果用户已存在(匹配电子邮件地址或登录名),则除非使用--skip-update
标志,否则将更新用户。
选项
<file>
The local or remote CSV file of users to import. If '-', then reads from STDIN.
[--send-email]
Send an email to new users with their account details.
[--skip-update]
Don't update users that already exist.
示例
# Import users from local CSV file
$ wp user import-csv /path/to/users.csv
Success: bobjones created.
Success: newuser1 created.
Success: existinguser created.
# Import users from remote CSV file
$ wp user import-csv http://example.com/users.csv
Sample users.csv file:
user_login,user_email,display_name,role
bobjones,[email protected],Bob Jones,contributor
newuser1,[email protected],New User,author
existinguser,[email protected],Existing User,administrator
wp用户列表
列出用户。
wp user list [--role=<role>] [--<field>=<value>] [--network] [--field=<field>] [--fields=<fields>] [--format=<format>]
根据WP_User_Query()支持的所有参数显示WordPress用户。
选项
[--role=<role>]
Only display users with a certain role.
[--<field>=<value>]
Control output by one or more arguments of WP_User_Query().
[--network]
List all users in the network for multisite.
[--field=<field>]
Prints the value of a single field for each user.
[--fields=<fields>]
Limit the output to specific object fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- ids
- json
- count
- yaml
---
可用字段
以下字段将为每个用户默认显示
- ID
- user_login
- display_name
- user_email
- user_registered
- roles
以下字段为可选字段
- user_pass
- user_nicename
- user_url
- user_activation_key
- user_status
- WordPress网站列表
- 列出多站安装中的所有网站。
- caps
- cap_key
- allcaps
- 过滤器
- url
示例
# List user IDs
$ wp user list --field=ID
1
# List users with administrator role
$ wp user list --role=administrator --format=csv
ID,user_login,display_name,user_email,user_registered,roles
1,supervisor,supervisor,[email protected],"2016-06-03 04:37:00",administrator
# List users with only given fields
$ wp user list --fields=display_name,user_email --format=json
[{"display_name":"supervisor","user_email":"[email protected]"}]
# List users ordered by the 'last_activity' meta value.
$ wp user list --meta_key=last_activity --orderby=meta_value_num
wp用户列表-caps
列出用户的所有能力。
wp user list-caps <user> [--format=<format>] [--origin=<origin>] [--exclude-role-names]
选项
<user>
User ID, user email, or login.
[--format=<format>]
Render output in a particular format.
---
default: list
options:
- list
- table
- csv
- json
- count
- yaml
---
[--origin=<origin>]
Render output in a particular format.
---
default: all
options:
- all
- user
- role
---
[--exclude-role-names]
Exclude capabilities that match role names from output.
示例
$ wp user list-caps 21
edit_product
create_premium_item
wp用户元数据
添加、更新、删除和列出用户自定义字段。
wp user meta
示例
# Add user meta
$ wp user meta add 123 bio "Mary is an WordPress developer."
Success: Added custom field.
# List user meta
$ wp user meta list 123 --keys=nickname,description,wp_capabilities
+---------+-----------------+--------------------------------+
| user_id | meta_key | meta_value |
+---------+-----------------+--------------------------------+
| 123 | nickname | supervisor |
| 123 | description | Mary is a WordPress developer. |
| 123 | wp_capabilities | {"administrator":true} |
+---------+-----------------+--------------------------------+
# Update user meta
$ wp user meta update 123 bio "Mary is an awesome WordPress developer."
Success: Updated custom field 'bio'.
# Delete user meta
$ wp user meta delete 123 bio
Success: Deleted custom field.
wp用户元数据添加
添加元字段。
wp user meta add <user> <key> <value> [--format=<format>]
选项
<user>
The user login, user email, or user ID of the user to add metadata for.
<key>
The metadata key.
<value>
The new metadata value.
[--format=<format>]
The serialization format for the value.
---
default: plaintext
options:
- plaintext
- json
---
示例
# Add user meta
$ wp user meta add 123 bio "Mary is an WordPress developer."
Success: Added custom field.
wp用户元数据删除
删除元字段。
wp user meta delete <user> <key> [<value>]
选项
<user>
The user login, user email, or user ID of the user to delete metadata from.
<key>
The metadata key.
[<value>]
The value to delete. If omitted, all rows with key will deleted.
示例
# Delete user meta
$ wp user meta delete 123 bio
Success: Deleted custom field.
wp用户元数据获取
获取元字段值。
wp user meta get <user> <key> [--format=<format>]
选项
<user>
The user login, user email, or user ID of the user to get metadata for.
<key>
The metadata key.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---
示例
# Get user meta
$ wp user meta get 123 bio
Mary is an WordPress developer.
# Get the primary site of a user (for multisite)
$ wp user meta get 2 primary_blog
3
wp用户元数据列表
列出与用户关联的所有元数据。
wp user meta list <user> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>] [--order=<order>] [--unserialize]
选项
<user>
The user login, user email, or user ID of the user to get metadata for.
[--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
- count
- yaml
---
[--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.
示例
# List user meta
$ wp user meta list 123 --keys=nickname,description,wp_capabilities
+---------+-----------------+--------------------------------+
| user_id | meta_key | meta_value |
+---------+-----------------+--------------------------------+
| 123 | nickname | supervisor |
| 123 | description | Mary is a WordPress developer. |
| 123 | wp_capabilities | {"administrator":true} |
+---------+-----------------+--------------------------------+
wp用户元数据修补
更新元字段的嵌套值。
wp user meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]
选项
<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用户元数据抽取
从元字段获取嵌套值。
wp user meta pluck <id> <key> <key-path>... [--format=<format>]
选项
<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用户元数据更新
更新元字段。
wp user meta update <user> <key> <value> [--format=<format>]
选项
<user>
The user login, user email, or user ID of the user to update metadata for.
<key>
The metadata key.
<value>
The new metadata value.
[--format=<format>]
The serialization format for the value.
---
default: plaintext
options:
- plaintext
- json
---
示例
# Update user meta
$ wp user meta update 123 bio "Mary is an awesome WordPress developer."
Success: Updated custom field 'bio'.
wp用户移除-cap
移除用户的能力。
wp user remove-cap <user> <cap>
选项
<user>
User ID, user email, or user login.
<cap>
The capability to be removed.
示例
$ wp user remove-cap 11 publish_newsletters
Success: Removed 'publish_newsletters' cap for supervisor (11).
$ wp user remove-cap 11 publish_posts
Error: The 'publish_posts' cap for supervisor (11) is inherited from a role.
$ wp user remove-cap 11 nonexistent_cap
Error: No such 'nonexistent_cap' cap for supervisor (11).
wp用户移除-角色
移除用户的角色。
wp user remove-role <user> [<role>...]
选项
<user>
User ID, user email, or user login.
[<role>...]
Remove the specified role(s) from the user.
示例
$ wp user remove-role 12 author
Success: Removed 'author' role for johndoe (12).
$ wp user remove-role 12 author editor
Success: Removed 'author', 'editor' roles for johndoe (12).
wp用户重置密码
重置一个或多个用户密码。
wp user reset-password <user>... [--skip-email] [--show-password] [--porcelain]
选项
<user>...
one or more user logins or IDs.
[--skip-email]
Don't send an email notification to the affected user(s).
[--show-password]
Show the new password(s).
[--porcelain]
Output only the new password(s).
示例
# Reset the password for two users and send them the change email.
$ wp user reset-password admin editor
Reset password for admin.
Reset password for editor.
Success: Passwords reset for 2 users.
# Reset and display the password.
$ wp user reset-password editor --show-password
Reset password for editor.
Password: N6hAau0fXZMN#rLCIirdEGOh
Success: Password reset for 1 user.
# Reset the password for one user, displaying only the new password, and not sending the change email.
$ wp user reset-password admin --skip-email --porcelain
yV6BP*!d70wg
# Reset password for all users.
$ wp user reset-password $(wp user list --format=ids)
Reset password for admin.
Reset password for editor.
Reset password for subscriber.
Success: Passwords reset for 3 users.
# Reset password for all users with a particular role.
$ wp user reset-password $(wp user list --format=ids --role=administrator)
Reset password for admin.
Success: Password reset for 1 user.
wp用户会话
销毁并列出用户的会话。
wp user session
示例
# List a user's sessions.
$ wp user session list [email protected] --format=csv
login_time,expiration_time,ip,ua
"2016-01-01 12:34:56","2016-02-01 12:34:56",127.0.0.1,"Mozilla/5.0..."
# Destroy the most recent session of the given user.
$ wp user session destroy admin
Success: Destroyed session. 3 sessions remaining.
wp用户会话销毁
销毁给定用户的会话。
wp user session destroy <user> [<token>] [--all]
选项
<user>
User ID, user email, or user login.
[<token>]
The token of the session to destroy. Defaults to the most recently created session.
[--all]
Destroy all of the user's sessions.
示例
# Destroy the most recent session of the given user.
$ wp user session destroy admin
Success: Destroyed session. 3 sessions remaining.
# Destroy a specific session of the given user.
$ wp user session destroy admin e073ad8540a9c2...
Success: Destroyed session. 2 sessions remaining.
# Destroy all the sessions of the given user.
$ wp user session destroy admin --all
Success: Destroyed all sessions.
# Destroy all sessions for all users.
$ wp user list --field=ID | xargs -n 1 wp user session destroy --all
Success: Destroyed all sessions.
Success: Destroyed all sessions.
wp用户会话列表
列出给定用户的会话。
wp user session list <user> [--fields=<fields>] [--format=<format>]
注意:该token
字段返回的是实际令牌的哈希值,而不是实际的令牌。真实的令牌不会被持久化,只能在客户端的相应cookie中找到。
选项
<user>
User ID, user email, or user login.
[--fields=<fields>]
Limit the output to specific fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
- count
- ids
---
可用字段
以下字段将为每个会话默认显示
- token
- login_time
- expiration_time
- ip
- ua
以下字段为可选字段
- expiration
- login
示例
# List a user's sessions.
$ wp user session list [email protected] --format=csv
login_time,expiration_time,ip,ua
"2016-01-01 12:34:56","2016-02-01 12:34:56",127.0.0.1,"Mozilla/5.0..."
wp用户设置-角色
设置用户角色。
wp user set-role <user> [<role>]
选项
<user>
User ID, user email, or user login.
[<role>]
Make the user have the specified role. If not passed, the default role is
used.
示例
$ wp user set-role 12 author
Success: Added johndoe (12) to http://example.com as author.
wp用户注册
管理多站安装上的注册。
wp user signup
示例
# List signups.
$ wp user signup list
+-----------+------------+---------------------+---------------------+--------+------------------+
| signup_id | user_login | user_email | registered | active | activation_key |
+-----------+------------+---------------------+---------------------+--------+------------------+
| 1 | bobuser | [email protected] | 2024-03-13 05:46:53 | 1 | 7320b2f009266618 |
| 2 | johndoe | [email protected] | 2024-03-13 06:24:44 | 0 | 9068d859186cd0b5 |
+-----------+------------+---------------------+---------------------+--------+------------------+
# Activate signup.
$ wp user signup activate 2
Signup 2 activated. Password: bZFSGsfzb9xs
Success: Activated 1 of 1 signups.
# Delete signup.
$ wp user signup delete 3
Signup 3 deleted.
Success: Deleted 1 of 1 signups.
wp用户注册激活
激活一个或多个注册。
wp user signup activate <signup>...
选项
<signup>...
The signup ID, user login, user email, or activation key of the signup(s) to activate.
示例
# Activate signup.
$ wp user signup activate 2
Signup 2 activated. Password: bZFSGsfzb9xs
Success: Activated 1 of 1 signups.
wp用户注册删除
删除一个或多个注册。
wp user signup delete [<signup>...] [--all]
选项
[<signup>...]
The signup ID, user login, user email, or activation key of the signup(s) to delete.
[--all]
If set, all signups will be deleted.
示例
# Delete signup.
$ wp user signup delete 3
Signup 3 deleted.
Success: Deleted 1 of 1 signups.
wp用户注册获取
获取有关注册的详细信息。
wp user signup get <signup> [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<signup>
The signup ID, user login, user email, or activation key.
[--field=<field>]
Instead of returning the whole signup, 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
---
示例
# Get signup.
$ wp user signup get 1 --field=user_login
bobuser
# Get signup and export to JSON file.
$ wp user signup get bobuser --format=json > bobuser.json
wp用户注册列表
列出注册。
wp user signup list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>] [--per_page=<per_page>]
[--<field>=<value>]
Filter the list by a specific field.
[--field=<field>]
Prints the value of a single field for each signup.
[--fields=<fields>]
Limit the output to specific object fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- ids
- json
- count
- yaml
---
[--per_page=<per_page>]
Limits the signups to the given number. Defaults to none.
可用字段
以下字段将为每个注册默认显示
- signup_id
- user_login
- user_email
- 在多站安装中删除一个网站。
- active
- activation_key
以下字段为可选字段
- 清空网站的内容(帖子、评论、术语和元数据)。
- 截断帖子、评论和术语表以清空网站内容。不影响网站配置(选项)或用户。
- title
- activated
- meta
示例
# List signup IDs.
$ wp user signup list --field=signup_id
1
# List all signups.
$ wp user signup list
+-----------+------------+---------------------+---------------------+--------+------------------+
| signup_id | user_login | user_email | registered | active | activation_key |
+-----------+------------+---------------------+---------------------+--------+------------------+
| 1 | bobuser | [email protected] | 2024-03-13 05:46:53 | 1 | 7320b2f009266618 |
| 2 | johndoe | [email protected] | 2024-03-13 06:24:44 | 0 | 9068d859186cd0b5 |
+-----------+------------+---------------------+---------------------+--------+------------------+
wp用户垃圾邮件
在多站上标记一个或多个用户为垃圾邮件。
wp user spam <user>...
选项
<user>...
The user login, user email, or user ID of the user(s) to mark as spam.
示例
# Mark user as spam.
$ wp user spam 123
User 123 marked as spam.
Success: Spammed 1 of 1 users.
wp用户术语
添加、更新、删除和列出用户术语。
wp user term
示例
# Set user terms
$ wp user term set 123 test category
Success: Set terms.
wp用户术语添加
将术语添加到对象中。
wp user term add <id> <taxonomy> <term>... [--by=<field>]
将术语追加到对象上现有的术语集中。
选项
<id>
The ID of the object.
<taxonomy>
The name of the taxonomy type to be added.
<term>...
The slug of the term or terms to be added.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
wp用户术语列表
列出与对象关联的所有术语。
wp user term list <id> <taxonomy>... [--field=<field>] [--fields=<fields>] [--format=<format>]
选项
<id>
ID for the object.
<taxonomy>...
One or more taxonomies to list.
[--field=<field>]
Prints the value of a single field for each term.
[--fields=<fields>]
Limit the output to specific row fields.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
- count
- ids
---
可用字段
以下字段将为每个术语默认显示
- term_id
- name
- slug
- taxonomy
以下字段为可选字段
- term_taxonomy_id
- description
- term_group
- parent
- count
wp用户术语删除
从对象中删除术语。
wp user term remove <id> <taxonomy> [<term>...] [--by=<field>] [--all]
选项
<id>
The ID of the object.
<taxonomy>
The name of the term's taxonomy.
[<term>...]
The slug of the term or terms to be removed from the object.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
[--all]
Remove all terms from the object.
wp用户术语设置
设置对象术语。
wp user term set <id> <taxonomy> <term>... [--by=<field>]
替换对象上的现有术语。
选项
<id>
The ID of the object.
<taxonomy>
The name of the taxonomy type to be updated.
<term>...
The slug of the term or terms to be updated.
[--by=<field>]
Explicitly handle the term value as a slug or id.
---
default: slug
options:
- slug
- id
---
wp用户取消垃圾邮件
从多站上的垃圾邮件中移除一个或多个用户。
wp user unspam <user>...
选项
<user>...
The user login, user email, or user ID of the user(s) to remove from spam.
示例
# Remove user from spam.
$ wp user unspam 123
User 123 removed from spam.
Success: Unspamed 1 of 1 users.
wp用户更新
更新现有用户。
wp user update <user>... [--user_pass=<password>] [--user_nicename=<nice_name>] [--user_url=<url>] [--user_email=<email>] [--display_name=<display_name>] [--nickname=<nickname>] [--first_name=<first_name>] [--last_name=<last_name>] [--description=<description>] [--rich_editing=<rich_editing>] [--user_registered=<yyyy-mm-dd-hh-ii-ss>] [--role=<role>] --<field>=<value> [--skip-email]
选项
<user>...
The user login, user email or user ID of the user(s) to update.
[--user_pass=<password>]
A string that contains the plain text password for the user.
[--user_nicename=<nice_name>]
A string that contains a URL-friendly name for the user. The default is the user's username.
[--user_url=<url>]
A string containing the user's URL for the user's web site.
[--user_email=<email>]
A string containing the user's email address.
[--display_name=<display_name>]
A string that will be shown on the site. Defaults to user's username.
[--nickname=<nickname>]
The user's nickname, defaults to the user's username.
[--first_name=<first_name>]
The user's first name.
[--last_name=<last_name>]
The user's last name.
[--description=<description>]
A string containing content about the user.
[--rich_editing=<rich_editing>]
A string for whether to enable the rich editor or not. False if not empty.
[--user_registered=<yyyy-mm-dd-hh-ii-ss>]
The date the user registered.
[--role=<role>]
A string used to set the user's role.
--<field>=<value>
One or more fields to update. For accepted fields, see wp_update_user().
[--skip-email]
Don't send an email notification to the user.
示例
# Update user
$ wp user update 123 --display_name=Mary --user_pass=marypass
Success: Updated user 123.
安装
此软件包包含在WP-CLI本身中,无需额外安装。
要安装此软件包的最新版本,该版本包含在WP-CLI中,请运行
wp package install [email protected]:wp-cli/entity-command.git
贡献
我们感谢您主动为这个项目做出贡献。
贡献不仅限于代码。我们鼓励您以最适合您能力的方式做出贡献,例如编写教程、在当地聚会中演示、帮助其他用户解决支持问题或修订我们的文档。
要了解更多信息,请查看WP-CLI的贡献指南。本包遵循这些政策和指南。
报告一个错误
你认为找到了一个错误?我们很乐意你帮助我们修复它。
在创建新的问题之前,你应该搜索现有的问题,看看是否有现成的解决方案,或者它是否已在更新的版本中修复。
一旦你进行了一些搜索,发现你的错误没有开放或已修复的问题,请创建一个新的问题。尽可能提供详细的信息,如果可能,提供明确的重现步骤。更多指导,请查看我们的错误报告文档。
创建一个pull请求
想要贡献一个新特性?请首先打开一个新问题,讨论这个特性是否适合这个项目。
一旦你决定投入时间将你的pull请求进行到底,请遵循我们创建pull请求的指南,以确保它是一个愉快的体验。有关在本地工作的详细信息,请参阅"设置"。
支持
GitHub问题不是用于一般支持问题的地方,但你还可以尝试其他途径:https://wp-cli.org/#support
此README.md是从项目的代码库动态生成的,使用wp scaffold package-readme
(文档)。要提出建议,请提交针对代码库相应部分的pull request。