Using WordPress with Drafts

guide
wordpress

#1

wordpress-logo

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:

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.

Drafts 5.4 Released - iOS 12 Ready, Siri Shortcuts, WordPress and more
#2

I am having no luck trying to get this to work. I do have multiple blogs associated to my Wordpress account, each has its own URL. I’ve created a new user id and password specific to the blog I want to post to from Drafts and provided that as credentials and that doesn’t work either.

Basically, in Drafts the action indicates that it posted successfully but the item never appears in any of the Drafts sections of any of the blogs. The Drafts action log does not show an error. I’ve forgot and retried credentials several times.


#3

Possible a couple of things are going on…most likely getting an error from your host. There is a bug that can report success on certain types of error using the step in 5.4 (fixed for 5.4.1). Try this scripted version and see what you are getting in the action log. It’s got more debugging info. Please open a ticket with the results (support@agiletortoise.com), we can better troubleshoot there.