WordPress XMLRPC – Posting Content From Outside WordPress Admin Panel

wordpress Posting Content via XML RPC

Many WordPress blog owners these days prefer to post their blog content from outside. This facilitates the site owners to post blog posts without even loging into their WordPress admin panel. WordPress supports XMLRPC which can take requests and perform specific operations i.e. ‘Add Post’, ‘Edit Post’, ‘View Recent Posts’ or ‘Save a draft’.

Lets start coding now, but before we go into any details lets ensure that our WordPress installation is allowing XMLRPC (default is turned off). Go to WordPress Admin => Settings => Writing and ensure the XML-RPC is enabled. Click save after checking the enable box. We are good and our WordPress is ready to take XML-RPC commands.

XML-RPC is by default enabled in WordPress 3.5+ that’s cool. On the other hand what if you are not using XMLRPC you can anytime disable it like this. Just place the following line of code in your themes functions.php file and you are all set.

But for the sake of our article, i assume you will not disable XMLRPC.

We will use IXR Library to incorporates both client and server classes, as it is designed to hide as much of the workings of XML-RPC from the user as possible. A key feature of the library is automatic type conversion from PHP types to XML-RPC types and vice-versa. This should enable developers to write web services with very little knowledge of the underlying XML-RPC standard.

Download IXR_Library.php.inc (rename it to IXR_Librabry.php.inc) or download the latest version from Incutio

Add a WordPress Blog Post via php

Get Recent 10 WordPress Blog Posts via php

Edit WordPress Blog Post via php

Posting Images and Marking Featured Via WordPress XMLRPC

The new wordpress thumbnail feature is so great, now all you have to do is upload an image and mark it as featured. If this is something you are looking for via WordPress XMLRPC then look at the following code

Code Explanation

Here is how it works

1. We are assuming you have already uploaded the file in your application, all you need to do is read the image file by this code

2. Connect to your WordPress XMLRPC

3. Now, upload the file to wordpress via XMLRPC

Finally lets see the full code example, how this uploaded image is marked as featured in your WordPress site.

Based on the code given below you can define your own logic of posting images in your article. Suppose you want to show the uploaded image within your content, you can append the $thumbnail_image within your $body object e.g.

I have made a centralized Word-press control panel where i am posting blog posts in more than 20 different blogs using the same admin area. There is no need to log into 20 blog accounts to post my content. I would love to hear your thoughts on this. Please leave me a comment and let me know. Don’t forget to subscribe our RSS to receive latest updates.our RSS to receive latest updates.

5 I like it
0 I don't like it