Use XMLRPC with CategoryID
-
Hi,
I use this function for publish posts using a php script outside the admin:
function wpPostXMLRPC($title, $body, $rpcurl, $username, $password, $categories, $keywords = '', $excerpt, $pubdate = '', $draftonly = false) { $content = array( 'title' => $title, 'description' => $body, 'mt_allow_comments' => 1, 'mt_allow_pings' => 1, 'post_type' => 'post', 'date_created_gmt' => '%pubdate%', // Just as place holder here. 'mt_keywords' => $keywords, 'mt_excerpt'=>$excerpt, 'categories' => $categories ); $params = array(0, $username, $password, $content, !$draftonly); $request = xmlrpc_encode_request('metaWeblog.newPost', $params, array('escaping'=>'markup')); // Now we need to set the real publishing date: $request = str_replace('%pubdate%', '' . $pubdate . '', $request); $ch = curl_init(); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_URL, $rpcurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); $results = curl_exec($ch); curl_close($ch); return $results; }I send categories as array through their name. But now, I need to send them through categoryID. Is it possible?
Can you help me modify this function for sending categories through ID ?
The topic ‘Use XMLRPC with CategoryID’ is closed to new replies.