Skip to content

Commit 99ff533

Browse files
authored
Add examples and update the documentation to the wp post term (#398)
* add more examples to the `wp post term` command * update CommandWithTerms docs * fix typo * update from slug to name * remove `(space-separated)`
1 parent e649e4b commit 99ff533

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Post_Term_Command.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@
88
*
99
* ## EXAMPLES
1010
*
11-
* # Set post terms
11+
* # Set category post term `test` to the post ID 123
1212
* $ wp post term set 123 test category
13+
* Success: Set term.
14+
*
15+
* # Set category post terms `test` and `apple` to the post ID 123
16+
* $ wp post term set 123 test apple category
1317
* Success: Set terms.
18+
*
19+
* # List category post terms for the post ID 123
20+
* $ wp post term list 123 category --fields=term_id,slug
21+
* +---------+-------+
22+
* | term_id | slug |
23+
* +---------+-------+
24+
* | 2 | apple |
25+
* | 3 | test |
26+
* +----------+------+
27+
*
28+
* # Remove category post terms `test` and `apple` for the post ID 123
29+
* $ wp post term remove 123 category test apple
30+
* Success: Removed terms.
31+
*
1432
*/
1533
class Post_Term_Command extends CommandWithTerms {
1634
protected $obj_type = 'post';

src/WP_CLI/CommandWithTerms.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ public function list_( $args, $assoc_args ) {
121121
* : The name of the term's taxonomy.
122122
*
123123
* [<term>...]
124-
* : The name of the term or terms to be removed from the object.
124+
* : The slug of the term or terms to be removed from the object.
125125
*
126126
* [--by=<field>]
127127
* : Explicitly handle the term value as a slug or id.
128128
* ---
129+
* default: slug
129130
* options:
130131
* - slug
131132
* - id
@@ -216,6 +217,7 @@ public function remove( $args, $assoc_args ) {
216217
* [--by=<field>]
217218
* : Explicitly handle the term value as a slug or id.
218219
* ---
220+
* default: slug
219221
* options:
220222
* - slug
221223
* - id
@@ -261,6 +263,7 @@ public function add( $args, $assoc_args ) {
261263
* [--by=<field>]
262264
* : Explicitly handle the term value as a slug or id.
263265
* ---
266+
* default: slug
264267
* options:
265268
* - slug
266269
* - id

0 commit comments

Comments
 (0)