Trying to publish new episodes using wp-cli and set fields


#1

Hello everyone,

I’m trying to automate some of my workflow, the first step is to create new episodes using wp-cli on the installation server. I can create a new episode, but I can’t find where to set parameters like the media slug. Even if I set them on the web interface, I can’t seem to find them, either as part of the post or in the meta data.

Here’s what I’ve tried:

$ wp post create --post_type=podcast --post_title='A sample episode'
Success: Created post 3263.

$ wp post meta list 3263
+---------+---------------+---------------------------------------------------+
| post_id | meta_key      | meta_value                                        |
+---------+---------------+---------------------------------------------------+
| 3263    | _podlove_guid | podlove-2019-01-17t17:57:10+00:00-ba5d558ff95b4a0 |
+---------+---------------+---------------------------------------------------+

#Then I edit it using the web interface and add a media slug

$ wp post meta list 3263
+---------+---------------+---------------------------------------------------+
| post_id | meta_key      | meta_value                                        |
+---------+---------------+---------------------------------------------------+
| 3263    | _podlove_guid | podlove-2019-01-17t17:57:10+00:00-ba5d558ff95b4a0 |
| 3263    | _edit_lock    | 1547747913:1                                      |
| 3263    | _edit_last    | 1                                                 |
+---------+---------------+---------------------------------------------------+

# I try and see if the info is in the post itself
$ wp post get 3263
+-----------------------+------------------------------------------------------------+
| Field                 | Value                                                      |
+-----------------------+------------------------------------------------------------+
| ID                    | 3263                                                       |
| post_author           | 1                                                          |
| post_date             | 2019-01-17 11:58:32                                        |
| post_date_gmt         | 0000-00-00 00:00:00                                        |
| post_content          |                                                            |
| post_title            | A sample episode                                           |
| post_excerpt          |                                                            |
| post_status           | draft                                                      |
| comment_status        | open                                                       |
| ping_status           | open                                                       |
| post_password         |                                                            |
| post_name             |                                                            |
| to_ping               |                                                            |
| pinged                |                                                            |
| post_modified         | 2019-01-17 11:58:32                                        |
| post_modified_gmt     | 2019-01-17 17:58:32                                        |
| post_content_filtered |                                                            |
| post_parent           | 0                                                          |
| guid                  | http://www.xxxxxxxxxxxxx/?post_type=podcast&p=3263 |
| menu_order            | 0                                                          |
| post_type             | podcast                                                    |
| post_mime_type        |                                                            |
| comment_count         | 0                                                          |
+-----------------------+------------------------------------------------------------+

Can you point me in some direction to where I can find the fields for media slug and others? They’re surely not accessible from these two commands. I see the podcast custom post type listed:

$ wp post-type get podcast 
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field           | Value                                                                                                                                                               |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name            | podcast                                                                                                                                                             |
| label           | Episodes                                                                                                                                                            |
| description     |                                                                                                                                                                     |
| hierarchical    | false                                                                                                                                                               |
| public          | true                                                                                                                                                                |
| capability_type | post                                                                                                                                                                |
| labels          | {"name":"Episodes","singular_name":"Episode","add_new":"Add New","add_new_item":"Add New Episode","edit_item":"Edit Episode","new_item":"New Episode","view_item":" |
|                 | View Episode","view_items":"Ver entradas","search_items":"Search Episodes","not_found":"No episodes found","not_found_in_trash":"No episodes found in Trash","paren |
|                 | t_item_colon":"","all_items":"All Episodes","archives":"All Episodes","attributes":"Atributos de entrada","insert_into_item":"Insertar en la entrada","uploaded_to_ |
|                 | this_item":"Subido a esta entrada","featured_image":"Imagen destacada","set_featured_image":"Establecer imagen destacada","remove_featured_image":"Quitar imagen de |
|                 | stacada","use_featured_image":"Usar como imagen destacada","filter_items_list":"Lista de entradas filtradas","items_list_navigation":"Navegaci\u00f3n por el listad |
|                 | o de entradas","items_list":"Lista de entradas","item_published":"Entrada publicada.","item_published_privately":"Entrada publicada de forma privada.","item_revert |
|                 | ed_to_draft":"Entrada convertida a borrador.","item_scheduled":"Entrada programada.","item_updated":"Entrada actualizada.","menu_name":"Episodes","name_admin_bar": |
|                 | "Episode"}                                                                                                                                                          |
| cap             | {"edit_post":"edit_post","read_post":"read_post","delete_post":"delete_post","edit_posts":"edit_posts","edit_others_posts":"edit_others_posts","publish_posts":"pub |
|                 | lish_posts","read_private_posts":"read_private_posts","read":"read","delete_posts":"delete_posts","delete_private_posts":"delete_private_posts","delete_published_p |
|                 | osts":"delete_published_posts","delete_others_posts":"delete_others_posts","edit_private_posts":"edit_private_posts","edit_published_posts":"edit_published_posts", |
|                 | "create_posts":"edit_posts"}                                                                                                                                        |
+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+

#2

Episode data does not use post meta but is in a different database table wp_podlove_episode and there are other wp_podlove_... tables for various relational data as well (assets, files, contributors etc.)

I haven’t looked into extending wp-cli but I assume you would need some kind of plugin/extension to make that work.


#3

Thanks for the answer. I’ll look and see if wp-cli can be extended to do that. I can at least create episodes with wp-cli, even if I have to enter the rest of the fields manually (it’s a start).