如何使用WordPress REST API指定post模板?



我正在使用Python的REST API创建WordPress帖子。

我找不到关于如何指定需要分配给已创建的帖子的帖子模板的任何文档或信息。

这是我用来指定post数据的格式:

post = {
'date': new_time,
'title': title,
'content': '',
'status': 'publish'
}

有谁知道一种方法来指定模板的帖子应该遵循?

经过一番研究,我设法找到了python-wordpress-xmlrpc的文档,其中规定了指定您希望页面遵循的模板的方法:

post = {
'date': new_time,
'title': title,
'template': 'customtemplate.php',
'content': '',
'status': 'publish'
}

值得注意的是,您必须为模板指定文件名,而不仅仅是模板名称。

只是离开文档,我不确定你是否可以使用'template':因为它是在WordPressPage下列出的,虽然它是从WordPressPost派生的,所以它可能是可能的。

最新更新