How do you upload image and set it as featured image on wordpress using C# metaweblog api? [closed]

StackOverflow https://stackoverflow.com/questions/18777840

Question

I'm using metaweblog api to post blogs on wordpress with c# as the language. Everything words like custom fields, tags, category and title. Problem is I can't seem to upload image and set the image as featured image. I've been searching for answers for 4 days already and still no luck. Maybe you guys could help me on this. Thank you very much.

Était-ce utile?

La solution

I found the answer to the problem. XML-RPC alone cannot set any uploaded image to featured image. Head over to this issue page http://core.trac.wordpress.org/ticket/15098. The patch allows returning the ID information of the uploaded image when using wp.uploadFile/metaWeblog.newMediaObject. Once the image ID(not the image URL) is returned, you can set it to wp_post_thumbnail and it should appear as featured image. Another workaround without going this route is by uploading the image first and you should be able to retrieve the URL of the image. Query ID information from wordpress database table called wp_posts where image id is equal to the name of the image uploaded. From there, you can then set the ID to wp_post_thumbnail. Thanks a lot.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top