【发布时间】:2018-09-11 03:25:06
【问题描述】:
使用 wordpress 为我的城镇图书馆制作网站。该网站将有数千个帖子,每本书一个。我正在尝试获取它,因此如果已经存在具有相同标题的帖子,它会在发布之前打印出一些内容让我知道。
我有这个 sn-p 的代码,但它已经很老了,而且 xmlrpc wordpress 的文档尤其是 python 的文档非常松散。
post_id=find_id(post.title)
if post_id:
print ("Sorry, we already have such a post" + post_id)
else:
pass
这是我的发布代码的其余部分。
#client info#
wp = Client(wp_url, wp_username, wp_password)
post = WordPressPost()
post.title = 'Dracula'
post.post_status = 'draft'
post.terms_names = {
'post_format': ['book'],
'category': [tag],
}
post.custom_fields = []
post.custom_fields.append({'key':'dp_desc','value':desc})
post.custom_fields.append({'key':'fifu_image_url','value':thumb})
wp.call(NewPost(post))
对不起,如果答案已经存在,我所看到的都在 php 中。
【问题讨论】:
标签: python wordpress python-3.x xml-rpc