WordPress remote posting using XMLRPC – to DRAFT

by techenet on July 7, 2009

     I don’t know why this was so difficult to find, and in the end I figured it out myself.

     If you use WordPress and make posts using the XMLRPC, you may be interested in setting the status. For example I use Jott quite a bit to capture an idea for a post on the go and have it appear in WordPress the next time I’m reviewing what to post.

     Jott supports the use of XMLRPC natively, and XMLRPC also has to be enabled in your blog. But once that’s done, if the client (ie. Jott in this case) doesn’t allow you to set the status, anything you send to the XMLRPC receiver gets automatically posted.

     In the case of Jott, this doesn’t work for me because my Jott’s are often unfinished and merely sent to WordPress as reminders. I still want to polish up the post before publishing.

     Enter a little PHP editing. To make posts received by the XMLRPC client post with a status of DRAFT, rather than PUBLISHED, do the following:

  • In the root directory of your WordPress blog locate the file “xmlrpc.php”
  • Download this file for editing
  • Edit the file and search for this line:    $post_status = ($publish) ? ‘publish’ : ‘draft’;
  • Change this line to be like this:     $post_status = ($publish) ? ‘draft’ : ‘publish’;
    • Basically swapping the ‘draft’ and ‘publish’
    • This tells WordPress that the default status to give an incoming post is “Draft” rather than “Publish”
  • There are about 3-5 lines just like that, just do a FIND and REPLACE so that you get them all, changing the order of the ‘draft’ and ‘publish’ for each line
  • Now save the file and re-upload it overwriting the server copy –  and presto, you’re done
Be Sociable, Share!

{ 1 comment }

Hydrolyze October 15, 2009 at 9:17 pm

Just wanted to say hello all. This is my first post.

I expect to learn a ton here.

Comments on this entry are closed.

Previous post:

Next post: