我有一个页面有一个新模板,我想用wp cli设置该新模板。
当我wp post get <id>
我得到如下输出:
+-----------------------+---------------------+
| 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 |
+-----------------------+---------------------+
这没有我要找的属性
page_template
当我尝试正确的属性键时:
wp post update 4 --page_template=\'New Home Page\'
我明白了Warning: The page template is invalid.
最合适的回答,由SO网友:Mike Lyons 整理而成
我在documentation 对于wp cli,它表示
[--<field>=<value>]
新帖子的关联参数。看见wp_insert_post().
随后显示:
\'page_template\' => [ <string> ] // Requires name of template file, eg. template.php.
命令为
wp post update 4 --page_template=\'new-home.php\'
SO网友:Prisoner 13
这没有我要找的属性page_template
尝试使用page_template
在里面fields
:
wp post list --post_type=page,post --fields=ID,post_title,post_name,post_type,page_template