Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How does one create a post, assign it to a category, add tags to it and set the featured image from a PHP script that exists somewhere on disk (say /usr/local/process.php) and isn't part of the Wordpress installation or infrastructure?

I searched for a couple of hours and can't find anything particularly useful. The only thing I'm stuck on is how to create the POST and add its metadata. The rest (like getting the images, extracting the caption etc) is already done.

Background

I'd like to automate the process to create posts for images I have. Unlike traditional import stuff, I'd like to replace images and update their posts and metadata if they already exist. The latter is important since I manage all my image metadata in Aperture. Every image has a unique name in the form of AAA99999999 and versions (such as a B&W and cropped) of images may have the format "AAA99999999 - Version NNN". If possible, I'd like to indicate that the posts of say "AAA99999999" and "AAA99999999 - Version 1" are related. I have about 2000 photos I'd like to import.

I'd like to use the script in the future to add and update new images.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You can remotely create posts programmatically via XML-RPC

e.g. PHP

http://www.nickycakes.com/post-to-wordpress-remotely-with-xmlrpc-in-php/

Java

http://code.google.com/p/wordpress-java/

Of note, the media library handles image EXIF data etc, it might be more convenient to switch from using posts to just displaying the latest uploaded attachments that do not have a parent post (attachments with a parent post are attached to a post or in a gallery)

share|improve this answer
    
There are some limitations using XML-RPC with the version of Wordpress I have installed. In addition, the metadata library sucks at IPTC information. The keywords, location and much more isn't extracted or searchable. Further, EXIF dates when the photos were taken doesn't seem to be extracted. –  Werner Strydom Apr 5 '12 at 18:37
    
You can extend the XML-RPC APIs, see here for how: kovshenin.com/2010/custom-xml-rpc-methods-in-wordpress you can use these to implement the postmeta additions you need –  Tom J Nowell Apr 5 '12 at 18:40
    
Also image attachments tend to have a tertiary post added that has the original attachment as a post_parent. This tertiary posts sole purpose is to hold additional metadata –  Tom J Nowell Apr 5 '12 at 18:40
    
Here's how to add custom fields wordpress.org/support/topic/… –  Tom J Nowell Apr 5 '12 at 18:41
    
Thanks this is what I was looking for. –  Werner Strydom Apr 5 '12 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.