【发布时间】:2015-09-16 00:52:44
【问题描述】:
我创建了一个脚本,当我运行它时会发布到我的网站(见下面的代码),一切正常,除了我似乎无法为我创建的页面设置模板。
from wordpress_xmlrpc import Client
from wordpress_xmlrpc.methods import posts, pages
from wordpress_xmlrpc import WordPressPage
client = Client(...)
page = WordPressPage()
page.template = 'template_name.php'
page.parent_id = '206'
page.title = 'Test'
page.slug = 'rrr'
page.content = 'Some text goes here'
page.post_status = 'publish'
page.id = client.call(posts.NewPost(page))
我在存储库 (https://github.com/maxcutler/python-wordpress-xmlrpc/issues/44) 中发现了这个问题,并尝试使用替代方法:
page.wp_page_template = 'template_name.php'
我还尝试了模板的名称和其他变体。当我使用 GetPageTemplates 代码时,我还发现我的模板:
templates = client.call(pages.GetPageTemplates())
我的所有模板都显示在这里。
有人使用此设置成功了吗?
【问题讨论】: