View on GitHub


A PHP XML-RPC client for Wordpress websites

Download this project as a .zip file Download this project as a tar.gz file

Wordpress XML-RPC PHP Client

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API

Created by Hieu Le

MIT licensed.

Current version: 2.4.0



You will need Composer installed on your machine to use this library Composer now is not required but recommended. Verify that composer is installed by typing this command

composer --version

Choose one of the following methods to install Wordpress XML-RPC PHP Client

Your project has used composer:

Add this dependency into your composer.json file


After that, run composer update to install this package.

Your project does not use composer:

Clone or download the archive of this package from github. Include all files in the src directory into your project and start using Wordpress XML-RPC Client. You have to update the code of this library manually if using it without Composer.

Required PHP extension is xmlrpc extension. The curl extension is optional be recommended.


All API call will be executed via an instance of the WordpressClient class. Since version 2.4.0, there is no mandatory parameters in the contructor. endPoint, username, and password can be updated anytime by calling setCredentials method. The last parameter in previous version contructor (which is an instance of \Illuminate\Log\Writer class) is deprecated and will be removed in the next major release. Below is an example of using this library:

# Your Wordpress website is at:
$endpoint = "";

# The Monolog logger instance
$wpLog = new Monolog\Logger('wp-xmlrpc');

# Create client instance
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
# Log error
$wpClient->onError(function($error, $event) use ($wpLog){
    $wpLog->addError($error, $event);

# Set the credentials for the next requests
$wpClient->setCredentials($endpoint, 'username', 'password');

If you have used logging feture of previous version of this library, you should update your code to use the new way of loggin as above, the Monolog instance can be replaced by any kinds of logging tool that you have.

To use date time value, you must use an instance of DateTime class instead of a string.

There will be 2 types of exception may be thrown from this library:

For API reference, visit Wordpress documentation or Library API documentation

User Agent (since 2.4.0)

The library use the default User Agent when contacting with Wordpress blogs. If you want to use onother one, pass your custom User Agent string into the setUserAgent method. If you passed a falsy value (null, false, ...) the default one will be used (thank @WarrenMoore)

Callbacks and events (since 2.4.0)

The library allow developers to listen on two events Sending and Error. You can add new closure as a callback for each events by calling on<event> method with the closure as parameter (see the onError example above).


This event is fired before each request is send to Wordpress blogs. $event is an array:

onError($errorMessage, $event)

This event is fired when the library run into errors, before any exception thrown. $errorMessage is a string. $event is an array:

Unit testing

By default, the project use recorded data as the default data for test suite. However, if you want to test with your own Wordpress installation, there are available options inside the ./tests/xmlrpc.yml file:

After update the ./tests/xmlrpc.yml file, run your test again.