Example of how to use node-wordpress

I am trying to run wordpress RPC methods with node-wordpress library but as there is no documentation at all, I am not sure what’s the proper way to run it.

Could you please show some examples if you had a chance to work with it?

Related posts

Leave a Reply

1 comment

  1. I’ve managed to get it done by reading the module itself.

    First you start the client:

    var wp = wordpress.createClient({
                "url": 'http://yourwordpressURL', 
                "username": 'user', 
                "password": 'pwd' 
    });
    

    than to add a post, for instance, just make the following call:

    wp.newPost({
          title: 'Your title',
          status: 'publish', //'publish, draft...',
          content: '<strong>This is the content</strong>',
          author: 3, // author id
          terms: {'category': [category_id]}
        },
        function() { 
          console.log(arguments);
        }
    });
    

    All the documentation for wordpress is in http://codex.wordpress.org/XML-RPC_WordPress_API/Posts

    Hope that helps.