Chapter 10. XML-RPC

WordPress is awesome, and you can build a lot of really cool applications just with it, but what if your application needs to communicate with other applications or other WordPress installations?

XML-RPC is a remote procedure call (RPC) protocol that uses XML to encode its calls and HTTP as a transport mechanism. WordPress uses an XML-RPC interface to easily allow developers to access and post data from other applications, including other WordPress sites.

We’ve compiled a list of some of the available methods of the wp_xmlrpc_server class along with the arguments that can be used and what values each function returns.

If you would like to follow along with the code examples for some of the following methods, set up the following function in a custom plugin or in your theme’s functions.php file. Also, be careful because some of the examples update and delete data:

<?php
add_action( 'init', 'wds_include_IXR' );
function wds_include_IXR() {
    // You need to include this file in order to use the IXR class.
    require_once ABSPATH . 'wp-includes/class-IXR.php';
    global $xmlrpc_url, $xmlrpc_user, $xmlrpc_pass;
    // Another WordPress site you want to push and pull data from
    $xmlrpc_url = 'http://anotherwordpresssite.com/xmlrpc.php';
    $xmlrpc_user = 'admin'; // Hope you're not using "admin" ;)
    $xmlrpc_pass = 'password'; // Really hope you're not using "password" ;)
}
?>

wp.getUsersBlogs

Calls the function wp_getUsersBlogs( $args ) and requires an array:

  • $username—A string of the username ...

Get Building Web Apps with WordPress now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.