wp post¶
Aide:
$ wp help post
NAME
wp post
DESCRIPTION
Manages posts, content, and meta.
SYNOPSIS
wp post <command>
SUBCOMMANDS
create Creates a new post.
delete Deletes an existing post.
edit Launches system editor to edit post content.
generate Generates some posts.
get Gets details about a post.
list Gets a list of posts.
meta Adds, updates, deletes, and lists post custom fields.
term Adds, updates, removes, and lists post terms.
update Updates one or more existing posts.
Liste des posts:
$ wp post list
+-----+---------------------------------+-----------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+-----------------------+---------------------+-------------+
| 184 | Welcome to the Gutenberg Editor | | 2018-08-03 13:55:41 | draft |
| 159 | zenphoto | zenphoto-3 | 2018-02-02 09:14:55 | publish |
| 154 | zenphoto | zenphoto-2 | 2018-02-02 09:12:51 | publish |
| 111 | Image en ligne | image-en-ligne | 2017-02-16 12:31:56 | publish |
| 106 | Flickr | flickr | 2017-02-15 18:58:02 | publish |
| 81 | WP - ZP | wp-zp | 2017-02-03 16:25:12 | publish |
| 78 | zen geo | zen-geo | 2017-02-02 06:28:45 | publish |
| 66 | Geo data | geo-data | 2017-01-31 14:02:20 | publish |
| 54 | Zenphoto | zenphoto | 2017-01-29 19:55:47 | publish |
| 27 | Bihoreau | bihoreau | 2017-01-29 17:23:20 | publish |
| 22 | Brame | brame | 2017-01-29 17:17:07 | publish |
| 9 | Bol d'Or Classic 2014 | bol-dor-classic-2014 | 2017-01-29 09:56:51 | publish |
| 1 | Bonjour tout le monde ! | bonjour-tout-le-monde | 2017-01-29 09:19:42 | publish |
+-----+---------------------------------+-----------------------+---------------------+-------------+
Liste des posts (status brouillon):
$ wp post list --post_status=draft
+-----+---------------------------------+-----------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+-----------+---------------------+-------------+
| 184 | Welcome to the Gutenberg Editor | | 2018-08-03 13:55:41 | draft |
+-----+---------------------------------+-----------+---------------------+-------------+
Liste des pages:
$ wp post list --post_type=page
+-----+---------------------------------+---------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+---------------------+---------------------+-------------+
| 186 | My test post | my-test-post | 2018-08-11 19:53:45 | publish |
| 136 | Map | map | 2017-02-21 09:55:17 | publish |
| 57 | Livre d'Or | livre-dor | 2017-01-29 20:18:16 | publish |
| 48 | License des photos | license-des-photos | 2017-01-29 18:35:44 | publish |
| 46 | Liens | liens | 2017-01-29 18:33:58 | publish |
| 39 | Ce mois-ci | ce-mois-ci | 2017-01-29 18:27:49 | publish |
| 37 | Contact | contact | 2017-01-29 18:22:58 | publish |
| 6 | Newsletter Sign Up Confirmation | nl-confirm-signup | 2017-01-29 09:36:46 | publish |
| 7 | Newsletter Unsubscription | nl-unsubscribe-page | 2017-01-29 09:36:46 | publish |
| 4 | Accueil | accueil | 2017-01-29 09:27:58 | publish |
| 2 | Page d’exemple | page-d-exemple | 2017-01-29 09:19:42 | publish |
+-----+---------------------------------+---------------------+---------------------+-------------+
Liste des posts ET pages:
$ wp post list --post_type=page,post --fields=ID,post_title,post_name,post_date,post_status,post_type
$ wp post list --post_type=page,post --fields=ID,post_title,post_name,post_status,post_type
+-----+---------------------------------+----------------------+-------------+-----------+
| ID | post_title | post_name | post_status | post_type |
+-----+---------------------------------+----------------------+-------------+-----------+
| 211 | Article 23 | post-23 | publish | post |
| 208 | Article 20 | post-20 | publish | post |
| 209 | Article 21 | post-21 | publish | post |
| 186 | My test post | my-test-post | publish | page |
| 184 | Welcome to the Gutenberg Editor | | draft | post |
| 159 | zenphoto | zenphoto-3 | publish | post |
| 154 | zenphoto | zenphoto-2 | publish | post |
| 136 | Map | map | publish | page |
| 111 | Image en ligne | image-en-ligne | publish | post |
| 106 | Flickr | flickr | publish | post |
| 81 | WP - ZP | wp-zp | publish | post |
| 78 | zen geo | zen-geo | publish | post |
| 66 | Geo data | geo-data | publish | post |
| 57 | Livre d'Or | livre-dor | publish | page |
| 54 | Zenphoto | zenphoto | publish | post |
| 48 | License des photos | license-des-photos | publish | page |
| 46 | Liens | liens | publish | page |
| 39 | Ce mois-ci | ce-mois-ci | publish | page |
| 37 | Contact | contact | publish | page |
| 27 | Bihoreau | bihoreau | publish | post |
| 22 | Brame | brame | publish | post |
| 9 | Bol d'Or Classic 2014 | bol-dor-classic-2014 | publish | post |
| 6 | Newsletter Sign Up Confirmation | nl-confirm-signup | publish | page |
| 7 | Newsletter Unsubscription | nl-unsubscribe-page | publish | page |
| 4 | Accueil | accueil | publish | page |
| 1 | Bonjour tout le monde ! | bonjour-tout-le-monde| publish | post |
| 2 | Page d’exemple | page-d-exemple | publish | page |
+-----+---------------------------------+----------------------+-------------+-----------+
Créer un post:
$ wp post create --post_type=page --post_status=publish --post_title='My test post' --post_content='This is a test post'
Success: Created post 186.
$ wp post create --post_title='Just a Post' --post_content='I wandered lonely as a cloud.' --post_status='publish'
Créer un post dont l'auteur est Bob (ID2):
$ wp post create --post_author=2 --post_status=publish --post_title='The Bob post' --post_content='This is a test post'
Success: Created post 213.
Supprimer un post:
$ wp post delete 187
Success: Trashed post 187.
Générer des posts:
$ wp post generate --count=3
Generating posts 100% [================================================================================================] 0:01 / 0:02
$ wp post list
+-----+---------------------------------+-----------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+-----------------------+---------------------+-------------+
| 189 | Article 13 | post-13 | 2018-08-11 20:28:12 | future |
| 190 | Article 14 | post-14 | 2018-08-11 20:28:12 | future |
| 191 | Article 15 | post-15 | 2018-08-11 20:28:12 | future |
| 184 | Welcome to the Gutenberg Editor | | 2018-08-03 13:55:41 | draft |
Générer des posts avec du dummy-text:
$ curl http://loripsum.net/api/4 | wp post generate --post_content --count=3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1991 0 1991 0 0 326 0 --:--:-- 0:00:06 --:--:-- 326
Generating posts 100% [===========================================] 0:00 / 0:00
$ wp post list
+-----+---------------------------------+-----------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+-----------------------+---------------------+-------------+
| 208 | Article 20 | post-20 | 2018-08-13 17:42:52 | future |
| 209 | Article 21 | post-21 | 2018-08-13 17:42:52 | future |
| 210 | Article 22 | post-22 | 2018-08-13 17:42:52 | future |
Générer des pages:
$ wp post generate --post_type=page --count=3
Generating posts 100% [================================================================================================] 0:00 / 0:00
$ wp post list --post_type=page
+-----+---------------------------------+---------------------+---------------------+-------------+
| ID | post_title | post_name | post_date | post_status |
+-----+---------------------------------+---------------------+---------------------+-------------+
| 201 | Page 12 | post-12 | 2018-08-11 20:37:31 | future |
| 202 | Page 13 | post-13 | 2018-08-11 20:37:31 | future |
| 203 | Page 14 | post-14 | 2018-08-11 20:37:31 | future |
| 186 | My test post | my-test-post | 2018-08-11 19:53:45 | publish |
| 136 | Map | map | 2017-02-21 09:55:17 | publish |
| 57 | Livre d'Or | livre-dor | 2017-01-29 20:18:16 | publish |
| 48 | License des photos | license-des-photos | 2017-01-29 18:35:44 | publish |
| 46 | Liens | liens | 2017-01-29 18:33:58 | publish |
| 39 | Ce mois-ci | ce-mois-ci | 2017-01-29 18:27:49 | publish |
| 37 | Contact | contact | 2017-01-29 18:22:58 | publish |
| 6 | Newsletter Sign Up Confirmation | nl-confirm-signup | 2017-01-29 09:36:46 | publish |
| 7 | Newsletter Unsubscription | nl-unsubscribe-page | 2017-01-29 09:36:46 | publish |
| 4 | Accueil | accueil | 2017-01-29 09:27:58 | publish |
| 2 | Page d’exemple | page-d-exemple | 2017-01-29 09:19:42 | publish |
+-----+---------------------------------+---------------------+---------------------+-------------+
Générer un post avec un prompt:
$ wp post generate --prompt
1/10 [--count=<number>]: 1
2/10 [--post_type=<type>]:
3/10 [--post_status=<status>]:
4/10 [--post_title=<post_title>]:
5/10 [--post_author=<login>]:
6/10 [--post_date=<yyyy-mm-dd-hh-ii-ss>]:
7/10 [--post_date_gmt=<yyyy-mm-dd-hh-ii-ss>]:
8/10 [--post_content] (Y/n):
9/10 [--max_depth=<number>]:
10/10 [--format=<format>]:
Generating posts 100% [================================================================================================] 0:00 / 0:00
Dernière mise à jour:
September 16, 2018