好的,我已经用python创建了一个脚本,使用“pythonwordpress xmlrpc”包我可以做任何事情,除了上传多个图片到wordpress,然后添加到画廊。在
以下是我上载单个图像文件然后设置为功能图像的代码:
fileImg = urlopen('image_url')
imageName = fileImg.url.split('/')[-1]
imageType = mimetypes.guess_type(str(fileImg.url))[0]
data = {
'name': imageName,
'type': imageType,
}
data['bits'] = xmlrpc_client.Binary(fileImg.read())
response = client.call(media.UploadFile(data))
attachment_id = response['id']
widget.thumbnail = attachment_id
注意:我知道如何上载多个文件,但我不知道如何在产品库中添加这些图像。在
目前没有回答
相关问题 更多 >
编程相关推荐