Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter theimben

    (@theimben)

    Thank you ??

    Thread Starter theimben

    (@theimben)

    That makes more sense but how would I put that in the function I have?

    theimben

    (@theimben)

    I’m looking how to do this too.

    Thread Starter theimben

    (@theimben)

    I can’t work out how to do this. This is what I’ve tried but it doesn’t work. It adds the post but not the custom fields.

    function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$categories=array(1)){
    	$categories = implode(",", $categories);
    	$XML = "<title>$title</title>".
    	"<category>$categories</category>".
    	$body;
    	$cflds = array('name' => 'a name', 'url' => 'https://www.google.com');
    	$content = array('post_type' => 'post', 'title' => $title, 'description' => $body, 'custom_fields' => $cflds);
    	$params = array('',$username,$password,$content,$XML,1);
    	$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
    	$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);
    	curl_exec($ch);
    	curl_close($ch);
    	echo '<pre>'.$request;
    }
Viewing 4 replies - 1 through 4 (of 4 total)