1
我试图用拇指图像添加新帖子,但我仍然无法取得成功。添加张贴图像缩略图到Wordpress博客与JoeBlogs/C#
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 = “603”; – tayfun
@tayfun只是为了检查,如果你去'domain.com?p = 603',它是否显示媒体附件? – enigma
是的,我现在没有。其重定向到一个图像xxx.com/?p=603 – tayfun