我正在尝试使用拇指图像添加新帖子,但我仍然无法成功。
public static int addContent(int postType, string title, string body, string post_thumbnail, string[] categories, string[] tags, DateTime dateCreated)
{
Post post = setPost(postType, title, body, post_thumbnail, categories, tags, dateCreated);
using (var wrapper = getWordPressWrapper())
{
return wrapper.NewPost(post, true);
}
}
获取 setPost 方法,
public static Post setPost(int postType, string title, string body, string post_thumbnail, string[] categories, string[] tags, DateTime dateCreated)
{
string type = postType == 1 ? "post" : "page";
var customFields = new CustomField[] {
new CustomField() {
// Don't pass in ID. It's auto assigned for new custom fields.
// ID = "name",
Key = "post_thumbnail",
Value = post_thumbnail
}
//,
// new CustomField() {
// // Don't pass in ID. It's auto assigned for new custom fields.
// // ID = "name",
// Key = "post-thumbnail",
// Value = post_thumbnail
//} ,
// new CustomField() {
// // Don't pass in ID. It's auto assigned for new custom fields.
// // ID = "name",
// Key = "post-thumbnails",
// Value = post_thumbnail
//} ,
// new CustomField() {
// // Don't pass in ID. It's auto assigned for new custom fields.
// // ID = "name",
// Key = "thumbnail",
// Value = post_thumbnail
//}
};
return new Post
{
PostType = type,
Title = title,
Body = body,
Categories = categories,
Tags = tags,
DateCreated = dateCreated,
CustomFields = customFields
};
}
如您所见,它的评论。我尝试了一切来发布拇指图像。
我尝试了 post_thumbnail、post-thumbnail、post-thumbnails、缩略图键,但没有任何反应。
我怎样才能做到这一点?