Man, I really don’t know what you’re trying to do here. Where are you putting that code? Are you sure it’s supposed to be ‘type_post’ and not ‘post_type’?
Thread Starter
hussan
(@hussan)
Hi,
i am trying add a custom post with xmlrpc , can i do it?
and, yes is post_type..
thanks
Where are you putting that code?
Thread Starter
hussan
(@hussan)
Hi,
i have a custom type called mynews and i am trying add a post with xmlrpc.
here is the code:
<?
require("xmlrpc/class-IXR.php");
$client = new IXR_Client('http://mysite.com/xmlrpc.php');
$USER = 'user';
$PASS = 'pass';
$content['title'] = 'Test title '.mt_rand();
$content['categories'] = array("");
$content['post_type'] = 'mynews';
// $content['custom_fields'] = array( array('key' => 'post_type','value'=>'downloadimpresa') );
$content['description'] = '<p>Lorem ipsum dolor sit amet</p>';
$content['mt_keywords'] = array('foo','bar');
if (!$client->query('metaWeblog.newPost','', $USER,$PASS, $content, true))
{
die( 'Error while creating a new post ' . $client->getErrorCode() ." : ". $client->getErrorMessage());
}
$ID = $client->getResponse();
if($ID)
{
echo 'Post published with ID:#'.$ID;
}
?>
when i try execute this code i have an error:
Error while creating a new post 401 : invalid post type
Can help me?
thanks
Sounds like it might be bug with WordPress’ implementation of xmlrpc. I presume you’re saving this code at the root of your site somewhere?
Thread Starter
hussan
(@hussan)
Hi,
no, this code isnt in root of wordpress instalation.
thanks
To repeat myself:
Where are you putting that code?
Thanks. It’s impossible to offer significant feedback without detailed information.
Thread Starter
hussan
(@hussan)
hi,
i put that code in /root_wordpress/directory/test.php
thanks