Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3029,6 +3029,22 @@ wp post-type get <post-type> [--field=<field>] [--fields=<fields>] [--format=<fo
- yaml
---

**AVAILABLE FIELDS**

These fields will be displayed by default for each post type:

* name
* label
* description
* hierarchical
* public
* capability_type
* labels
* cap
* supports

There are no optionally available fields.

**EXAMPLES**

# Get details about the 'page' post type.
Expand Down Expand Up @@ -3070,7 +3086,7 @@ wp post-type list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--f

**AVAILABLE FIELDS**

These fields will be displayed by default for each term:
These fields will be displayed by default for each post type:

* name
* label
Expand Down
8 changes: 8 additions & 0 deletions features/post-type.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ Feature: Manage WordPress post types
| Field | Value |
| name | page |
| label | Pages |
And STDOUT should contain:
"""
supports
"""
And STDOUT should contain:
"""
"title":true
"""
22 changes: 20 additions & 2 deletions src/Post_Type_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Post_Type_Command extends WP_CLI_Command {
*
* ## AVAILABLE FIELDS
*
* These fields will be displayed by default for each term:
* These fields will be displayed by default for each post type:
*
* * name
* * label
Expand Down Expand Up @@ -130,6 +130,22 @@ public function list_( $args, $assoc_args ) {
* - yaml
* ---
*
* ## AVAILABLE FIELDS
*
* These fields will be displayed by default for each post type:
*
* * name
* * label
* * description
* * hierarchical
* * public
* * capability_type
* * labels
* * cap
* * supports
*
* There are no optionally available fields.
*
* ## EXAMPLES
*
* # Get details about the 'page' post type.
Expand All @@ -146,7 +162,8 @@ public function get( $args, $assoc_args ) {
if ( empty( $assoc_args['fields'] ) ) {
$default_fields = array_merge( $this->fields, array(
'labels',
'cap'
'cap',
'supports',
) );

$assoc_args['fields'] = $default_fields;
Expand All @@ -161,6 +178,7 @@ public function get( $args, $assoc_args ) {
'capability_type' => $post_type->capability_type,
'labels' => $post_type->labels,
'cap' => $post_type->cap,
'supports' => get_all_post_type_supports( $post_type->name ),
);

$formatter = $this->get_formatter( $assoc_args );
Expand Down