• Public
  • Public/Protected
  • All


Script integration with WordPress sites via the WordPress XML-RPC API. Currently this object has one runMethod function which can be used to call any method available in the XML-RPC interface.

The WordPress API offers access to a wide variety of functions, including posting, but also retrieving information about categories and tags, or reading posts contents.

Drafts WordPress object simplifies working with the XML-RPC interface by accepting input parameters as Javascript objects and converting them to the require XML to make requests of the WordPress site. Similarly, it converts to XML returned by WordPress to Javascript objects. Otherwise it is an exact passthrough, so the WordPress API reference should be used to determine method names (e.g. wp.newPost, wp.getTaxonomies) available, the appropriate parameters to send.

The WordPress XML-RPC API authenticates via username and password, so it is highly recommended you interact only over HTTPS secure connections, and use Credential objects to store host/username/password values, rather than hard-coding them in actions.


// setup values to use in post
let title = draft.processTemplate("<a href="calendar.html#title">title</a>");
let body = draft.processTemplate("<a href="gmailmessage.html#body">body</a>");

// create credentials for site
let cred = Credential.createWithHostUsernamePassword("WordPress", "WordPress  * credentials. Include full URL (with http://) of the home page of your WordPress  * site in the host field.");

// create WordPress object and make request
let wp = WordPress.create(cred.getValue("host"), 1, "", "");
let method = "wp.newPost"
let params = [
    1, // blog_id, in most cases just use 1
        "post_title": title,
        "post_content": body,
        "post_status": "draft",
        "terms_names" : { // assign categories and tags
            "category" : ["Cat1", "BAD"],
            "post_tag" : ["Test1", "NOT-TAG"]

let response = wp.runMethod(method, params);
if (response.success) {
    let params = response.params;
    console.log("Create WordPress post id: " + params[0]);
else {
    console.log("HTTP Status: " + response.statusCode);
    console.log("Fault: " + response.error);


  • WordPress




  • getCategories(): object[] | undefined


  • getPost(postId: string): object | undefined


  • getPostStatusList(): object[] | undefined


  • getPosts(filter?: any): object[] | undefined
  • Parameters

    • Optional filter: any

    Returns object[] | undefined


  • getTags(): object[] | undefined


  • getTaxonomies(): object[] | undefined


  • getTaxonomy(taxonomy?: string): object | undefined
  • Parameters

    • Optional taxonomy: string

    Returns object | undefined


  • getTerms(taxonomy?: string, filter?: any): object[] | undefined
  • Parameters

    • Optional taxonomy: string
    • Optional filter: any

    Returns object[] | undefined


  • newPost(content: string): string | undefined


  • Run an XML-RPC API method on a WordPress site. Any method name supported by the WordPress XML-RPC API can be used, as long as the authentication information provided has appropriate permissions on the site.


    • methodName: string

      The method name as documented in the WordPress XML-RPC API, for example wp.newPost to create a new post.

    • parameters: any[]

      Parameters should be a Javascript array of parameters for the method being used. These vary depending on the method and should follow the documentation provided by WordPress.

    Returns XMLRPCResponse

Static create

  • create(siteURL: string, blogId: string, username?: string, password?: string): WordPress
  • Parameters

    • siteURL: string

      This should be the full URL to the home page of the WordPress site. e.g. https://mysite.com or https://mysite.com/blog/.

    • blogId: string

      For most WordPress installations, use 1.

    • Optional username: string

      Username to login to the WordPress site. Optional if only using runMethod, as credentials will be required directly in parameters for those calls.

    • Optional password: string

      Password to login to the WordPress site. Optional if only using runMethod, as credentials will be required directly in parameters for those calls.

    Returns WordPress


  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc