Perl WordPress::XMLRPC categories not being set.

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-04-13T08:51:20Z Indexed on 2010/04/13 8:52 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

The following code works fine to upload a new post to a WordPress blog but for the life of me I can't seem to get the categories to be set.

The categories exist. I've tried all lower case, tried case-matching, tried the slug version. Nothing works. No matter how I try passing the categories, the post gets assigned only to the default category.

I've scoured the web to find other pieces of sample code and none mention the actual code semantics of how to assign post to certain categories using the WordPress::XMLRPC module.

use WordPress::XMLRPC;

my $o = WordPress::XMLRPC->new;  
$o->username('username');
$o->password('password');
$o->proxy('http://blogdomain.com/xmlrpc.php');
$o->server() || die "$!";

my $hashref = {
 'title' => 'Test New Post 999 555456782',
 'categories' => ['Categorie1', 'Categorie2'],
 'description' => '<p>Here is the content</p>',
 'mt_keywords' => 'tag1, tag2, tag3',
 'mt_allow_comments' => 1,
};

my $ID = $o->newPost($hashref, 1);

© Stack Overflow or respective owner

Related posts about perl

Related posts about Wordpress