Here is how to create a single post with XML-RPC.
Other details are similar to http://coding-2015.blogspot.com/2015/04/delete-wordpress-posts-pages-with-ixr.html
query('wp.newPost', '', $username, $password, $content, true)) { die('Error while creating a new post' . $client->getErrorCode() . " : " . $client->getErrorMessage()) . "\n"; } $ID = $client->getResponse(); if ($ID) { echo 'Post published with ID:#' . $ID . "\n"; } return $ID; } $url = 'http://yourwordpressurl/xmlrpc.php'; $USER = 'username'; $PASS = 'password'; $title = "Page Title"; $path = "page-title"; $body = "this is content body"; wordpress_create_post($url, $USER, $PASS, $title, $path, $body); ?>
The output in the console should be like this:
>php wordpress-create-single.php
Post published with ID:#4956
That's it
No comments:
Post a Comment