将图像插入wordpress帖子

时间:2015-06-20 13:14:06

标签: python wordpress xmlrpclib

如何将图片从网址插入wordpress?我使用下面的代码插入一篇文章。我不想只附上缩略图。

def write_post_to_wordpress(summary,title, keywords, category):
    date_now=str(datetime.datetime.today())[:-10]
    date_created = xmlrpclib.DateTime(
        datetime.datetime.strptime(str(date_now), "%Y-%m-%d %H:%M")
    )
    categories = [category]
    data = {
        'title': title,
        'description': summary,
        'dateCreated': date_created, 
        'categories': categories,
        'mt_keywords': keywords
    }
    post_id = server.metaWeblog.newPost(
        wp_blogid,
        wp_username,
        wp_password,
        data,
        status_published
    )
    return post_id

0 个答案:

没有答案