I’m using this code and it works but i want more.
$function_name = "wp.newPost";
$url = "https://wordpressurl/xmlrpc.php";
$client = new xmlrpc_client($url);
$client->return_type = 'phpvals';
$message = new xmlrpcmsg(
$function_name,
array(
new xmlrpcval(0, "int"),
new xmlrpcval("username", "string"),
new xmlrpcval("password", "string"),
new xmlrpcval(
array(
"post_type" => new xmlrpcval("post", "string"),
"post_status" => new xmlrpcval("draft", "string"),
"post_title" => new xmlrpcval("$releasename $dlsiteenglish $dlsitejapanese", "string"),
"post_author" => new xmlrpcval(1, "int"),
"post_content" => new xmlrpcval("$content", "string"),
"comment_status" => new xmlrpcval("open", "string")
),
"struct"
)
)
);
$resp = $client->send($message);
if ($resp->faultCode()) echo 'KO. Error: '.$resp->faultString(); else echo "Post id is: " . $resp->value() . "\n";
And i’ve been trying to use this to make sense of the formatting:
https://codex.wordpress.org/XML-RPC_WordPress_API/Posts
Does anyone know how to add categories and tags? I tried many different iterations and none of it worked.
I would also like to eventually add featured image and image gallery to the post.
Can anyone help out? or suggest a different way to do this or easier way?
thank you very much in advance!