Drafts (v5.4 or greater) can be used with the WordPress blogging and content management system via integration with the WordPress XML-RPC API.
The XML-RPC API is available, and enabled by default, in WordPress version 3.5 or greater, but its availability, and limits on its use, may vary by where your WordPress site is hosted. It is highly recommend you use secure connections (https) to connect to your site using XML-RPC.
Posting to WordPress
Drafts provides a WordPress action step which allows creation and publishing of posts on a WordPress site. Example action:
This example posts to a WordPress blog in âDraftâ status (to be published in the web interface later), using the first line of the title as the title of the post, and remaining text as the content.
This basic example can be modified to control post status, automatically assign categories, tags and even custom fields. The details of available options can be found in the action step documentation.
WordPress Credentials and Sites
The first time you run an action using a WordPress action step, you will be asked for details required to connect to your site. These include the host name of the home page of the WordPress site, and your username and password. These will be stored for future use with the action.
Be sure to enter the full URL to the home page of the WordPress site when prompted. This includes the âhttp://â or âhttps://â the host name and partial path if the site is hosted in a sub-directory, like: âhttps://mysite.com/blog/â.
If you only post to one WordPress site, no additional configuration is needed. If you wish to have actions which post to different WordPress sites, configure a unique value in the âCredential Identifierâ field of the WordPress action step. All WordPress action steps with the same âCredential Identifierâ will share the same login. This value can be anything, but using something like the host name of the site for easy identification is recommended.
To reset credentials and login again, visit Settings > Credentials and âForgetâ the WordPress credentials. Read more about Credentials.
Using the WordPress app share extension
WordPress also offers their own WordPress iOS app which can be used to post to WordPress.com of self-hosted WordPress blogs. The app offers a share extension, so if it is installed an configured on your device, it can be used via the Drafts âShareâ action and the system share sheet. This approach is less automated, but is often a good choice if you want to make some selections of categories, tags, published status, etc., on the fly when you publish.
Scripting and the XML-RPC API
Drafts provides a WordPress
scripting object which can be used to make direct requests to any methods available in the WordPress XML-RPC API. The object provides several convenience methods to fetch taxonomy information, etc., and also a runMethod
function to call any method available in the API.
Using scripting, WordPress posts and taxonomy information can be queried, downloaded, updated, existing posts can be imports and more.
This wrapper handles the XML part of XML-RPC, making it easy to work with the WordPress API in Javascript, but is an advanced topic. For details, visit the scripting reference.
Example Scripted Actions:
- WordPress - Get Recent Posts
- Retrieves recents posts from the WordPress site and creates a new draft with a summary of the posts.
- WordPress - New Post
- Demonstrates creating a new post via script.
Troubleshooting
If you have trouble posting to your WordPress blog, try the following:
- If posting has never worked, ensure the site host, username and password are all correct and entered properly. You can forget the credentials in settings and re-run the action to re-enter them.
- Check the action log after running a failed action for details on what error occurred.
- Check with your hosting provider to be sure that the WordPress XML-RPC interface is allowed and enabled on WordPress installations on their service.