通过 XML-RPC 为 WordPress 帖子设置特色图片 [英] set featured image for WordPress post via XML-RPC

查看:41
本文介绍了通过 XML-RPC 为 WordPress 帖子设置特色图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约 6 个月前,WordPress API 进行了更新,允许设置帖子的缩略图(或特色)图像.

About 6 months ago there was an update to the WordPress API which allows setting a post's thumbnail (or featured) image.

http://www.maxcutler.com/2012/04/04/xml-rpc-in-wordpress-3-4/

我正在尝试使用它,但它对我不起作用.我想知道我可能做错了什么.我正在调用 XML-RPC newPost 方法来创建一个帖子并传递媒体库中现有资产的媒体 ID(在媒体库中称为attachment_id) 正在创建新帖子,并且正在创建所有其他属性设置,除了特色图像.

I'm trying to use it but it's not working for me. I'd like to know what I may be doing wrong. I'm calling the XML-RPC newPost method to create a post and passing the Media ID of an existing asset in the media library (known as the attachment_id in the media library) The new post is being created and all the other properties are being set, except for the featured image.

我验证了我的 wordpress api 版本,果然在 class-wp-xmlrpc-server.php 中我看到了新帖子功能部分的评论:"* post_thumbnail - 用作帖子缩略图/特色图片的媒体项目 ID"

I verified my version of the wordpress api, and sure enough in class-wp-xmlrpc-server.php I see the comment in the new post function section: "* post_thumbnail - ID of a media item to use as the post thumbnail/featured image"

所有其他属性都在工作.我可以通过 XML-RPC 向媒体库添加新图像.我可以创建和更新帖子并设置它们的标签、标题、描述、自定义字段值和类别.当我尝试设置 post_thumbnail 值时,我没有收到任何错误.即使我传入了一个不存在的媒体 ID,这看起来也很奇怪.

All the other properties are working. I can add new images to the media library via XML-RPC. I can create and update posts and set their tags, titles, descriptions, custom field values, and categories. I don't get any errors when I try to set the post_thumbnail value. Even if I pass in a non-existent media id, which seems odd.

推荐答案

arrrg!此 WP 3.4 版票具有误导性!http://core.trac.wordpress.org/ticket/20396

arrrg! this WP version 3.4 ticket is misleading! http://core.trac.wordpress.org/ticket/20396

是wp_post_thumbnail"而不是post_thumbnail"

it's "wp_post_thumbnail" not "post_thumbnail"

这篇关于通过 XML-RPC 为 WordPress 帖子设置特色图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆