【发布时间】:2018-10-30 09:54:42
【问题描述】:
我整天都在尝试,但只有我可以创建帖子,而不是页面。
我修改了文件 wordpress\lib\wordpress.js 并将 wp.newPost 更改为 wp.newPage 但标题和内容为空,我确定它不正确。
我尝试了数千次和方法,但只有我可以得到帖子类型。
这是代码:
var wordpress = require( "wordpress" );
var client = wordpress.createClient({
url: "http://MY-URL",
username: "MYUSERNAME",
password: "MAYPWD@200"
});
client.newPost({
postType: "page",
title: "Page from Node.js",
content: "This page was created sending remotely post from
Node.js.....",
status: "publish",
termNames: {
"category": ["Javascript", "Node"],
"post_tag": ["api", "js", "remote"]
}
}, function( error, data ) {
console.log( "Post sent! The server replied with the following:\n" );
console.log( arguments );
console.log("\n");
});
client.getPosts(function( error, posts ) {
console.log( "Found " + posts.length + " posts!" );
});
缺少什么?
【问题讨论】: