voceconnect / multi-post-thumbnails

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
143 stars 63 forks source link

Adding images to multi-post-thumbnails fields using XML-RPC #38

Closed haabe closed 10 years ago

haabe commented 10 years ago

I just learned that I need to migrate data from an old sql database to a WP publication. The publication uses multi-post-thumbnails, and I need to direct the image data to the corresponding fields in the posts.

Adding an ordinary thumbnail using post_thumbnail in wp.newPost is easy, but how do I add a multi-post-thumbnail?

I tried 'post_customfields' => array( 'post[field-name]_thumbnail' => $imageid ) but that was obviously wrong.

chrisscott commented 10 years ago

The meta key gets built (code) using the post_type and id array values used to register the thumbnail. So, for the 'post' post type and an id of 'secondary-image' the meta key would be post_secondary-image_thumbnail_id and would be the meta key you can pass in to your call along with the image ID to be the thumbnail.