If you want to post several items, there are only a few things that change for every post:
- The title of the post.
- The contents of the post
- The category of the post
- The keywords (optional, but I guess you are using it).
The RPC URL, username, password and encoding is standard because I also suppose you're posting it onto the same website. So we only have to store the 4 named items in an array that we can run through. I store the items in another array, so we have an array of arrays.
You could easily write something like this:
// We create a post array that contains an array per post.
// I put in the data index based. First item is title, second is content body, third is category, fourth is keywords.
$posts = array(
array('Title','Contents','category','keywords'),
array('Another post','More content','another category ID','etc.'),
// You can add more items if you want.
);
// These are just general settings that are the same for each post.
$rpcurl = 'http://www.yourwordpressblog.com/xmlrpc.php';
$username = 'myusername';
$password = 'mypassword';
$encoding ='UTF-8';
foreach($posts AS $Post)
{
// From the foreach we get an array with post data each cycle.
// To keep things a bit clear, I will extract the data to seperate variables..
$title = $Post[0];
$body = $Post[1];
$category = $Post[2];
$keywords = $Post[3];
wpPostXMLRPC($title,$body,$rpcurl,$username, $password,$category,$keywords,$encoding);
}