I am pretty much new to wordpress. My requirement is that i need to make a post from an external source using ajax to wordpress site. The post data merely contain “posttitle,description,etc…” and an “imageurl” which is pre-uploaded to amazon s3.
I am succcessfully able to post the data using the following reference
http://codex.wordpress.org/Function_Reference/wp_insert_post#Example
but i need to save the s3 url (external image) to worpress post tables and show it as a featured image without again uploading to wordpress server.
To figure out how the images are being saved, I logged into wp admin and created a post with featured image, searched wp tables for image path and it is saving image relative path in ‘postmeta’ table as below.
The images are stored with relative reference path.Then i thought even if i forcefully insert s3 url (which is absolute),wordpress might not be able to recoginize it as it might always be searching for local files.How do i achieve inserting s3 urls into wordpress tables and make them show up in my posts.
I searched everywhere but couldn’t find solution for this particular case.
Any help is appreciated. Thanks in advance.
You can use a absolute path in the
guid
field in the posts table for the featured image withpost_type
set toattachment
.The image is set to Featured for a given post by adding it to the
postmeta
table with the post ID and the featured image post ID andmeta_key
=_thumbnail_id
.