【问题标题】:Example of how to use node-wordpress如何使用 node-wordpress 的示例
【发布时间】:2012-09-19 04:33:48
【问题描述】:

我正在尝试使用 node-wordpress 库运行 wordpress RPC 方法,但由于根本没有文档,我不确定运行它的正确方法是什么。

如果您有机会使用它,能否举一些例子?

【问题讨论】:

    标签: wordpress node.js


    【解决方案1】:

    我已经通过阅读模块本身来完成它。

    首先你启动客户端:

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

    比添加帖子,例如,只需拨打以下电话:

    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);
        }
    });
    

    wordpress 的所有文档都在http://codex.wordpress.org/XML-RPC_WordPress_API/Posts

    希望对您有所帮助。

    【讨论】:

    • 这为我节省了大约 3 个小时的麻烦拍摄时间。干杯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2012-07-27
    • 2012-05-28
    相关资源
    最近更新 更多