php - set s3 image as a featured image in wordpress post while posting the post programatically from an external source -
i pretty new wordpress. requirement need make post external source using ajax wordpress site. post data merely contain "posttitle,description,etc..." , "imageurl" pre-uploaded amazon s3. i succcessfully able post data using following reference http://codex.wordpress.org/function_reference/wp_insert_post#example
but need save s3 url (external image) worpress post tables , show featured image without again uploading wordpress server.
to figure out how images being saved, logged wp admin , created post featured image, searched wp tables image path , saving image relative path in 'postmeta' table below.
the images stored relative reference path.then thought if forcefully insert s3 url (which absolute),wordpress might not able recoginize might searching local files.how achieve inserting s3 urls wordpress tables , make them show in posts. searched everywhere couldn't find solution particular case. appreciated. in advance.
you can use absolute path in guid
field in posts table featured image post_type
set attachment
.
the image set featured given post adding postmeta
table post id , featured image post id , meta_key
= _thumbnail_id
.
insert $wp->post (post_type, guid, status, post_mime_type) values ('attachment', '<imageurl>', 'publish', 'image/jpeg'); insert $wp->postmeta (meta_value, meta_key, post_id) values ('<imagepostid>', '_thumbnail_id', '<postid>');
Comments
Post a Comment