I have a page that has a new template, and I want to set that new template with wp-cli.
When I wp post get <id>
I get an output like the following:
+-----------------------+---------------------+
| Field | Value |
+-----------------------+---------------------+
| ID | 4 |
| post_author | 5 |
| post_date | 2012-03-09 13:11:38 |
| post_date_gmt | 0000-00-00 00:00:00 |
| post_content | |
| post_title | Home Page |
| post_excerpt | |
| post_status | publish |
| comment_status | closed |
| ping_status | open |
| post_password | |
| post_name | home |
| to_ping | |
| pinged | |
| post_modified | 2015-06-04 12:23:41 |
| post_modified_gmt | 2015-06-04 19:23:41 |
| post_content_filtered | |
| post_parent | 0 |
| guid | /?page_id=4 |
| menu_order | 0 |
| post_type | page |
| post_mime_type | |
| comment_count | 0 |
+-----------------------+---------------------+
This doesn't have the attribute I am looking for page_template
When I try what seems to be the correct attribute key:
wp post update 4 --page_template='New Home Page'
I get Warning: The page template is invalid.
I have a page that has a new template, and I want to set that new template with wp-cli.
When I wp post get <id>
I get an output like the following:
+-----------------------+---------------------+
| Field | Value |
+-----------------------+---------------------+
| ID | 4 |
| post_author | 5 |
| post_date | 2012-03-09 13:11:38 |
| post_date_gmt | 0000-00-00 00:00:00 |
| post_content | |
| post_title | Home Page |
| post_excerpt | |
| post_status | publish |
| comment_status | closed |
| ping_status | open |
| post_password | |
| post_name | home |
| to_ping | |
| pinged | |
| post_modified | 2015-06-04 12:23:41 |
| post_modified_gmt | 2015-06-04 19:23:41 |
| post_content_filtered | |
| post_parent | 0 |
| guid | /?page_id=4 |
| menu_order | 0 |
| post_type | page |
| post_mime_type | |
| comment_count | 0 |
+-----------------------+---------------------+
This doesn't have the attribute I am looking for page_template
When I try what seems to be the correct attribute key:
wp post update 4 --page_template='New Home Page'
I get Warning: The page template is invalid.
I found that in the documentation for wp-cli it says
[--<field>=<value>]
Associative args for the new post. See wp_insert_post().
Which then subsequently shows:
'page_template' => [ <string> ] // Requires name of template file, eg. template.php.
The command is wp post update 4 --page_template='new-home.php'
This doesn't have the attribute I am looking for
page_template
Try using page_template
in fields
:
wp post list --post_type=page,post --fields=ID,post_title,post_name,post_type,page_template