WordPress::API::Category
Ideally you wouldn't use this object directly.
my $wp = new WordPress::API({ proxy => 'http://whatvr.net/xmlrpc.php', username => 'pacman', password => 'misspacman', }); # create a new category my $cat = $wp->category; $cat->categoryName('Writing Instruments'); $cat->save or die($wp->errstr); # how would we access via browser? $cat->htmlUrl; # let's create a sub category .. my $parent_category_id = $cat->id; my $subcat = $wp->category(); $subcat->categoryName('Pencils'); $subcat->parentID( $parent_category_id ); my $subcatid = $subcat->save; # remember save returns id
To fetch a category and its attributes, you can provide an id (or a categoryName?) This is required before you call load() to fetch the data from the server.
$cat->categoryName('Super Stuff'); # not sure about this yet $cat->id(34);
Setget perl method. Argument is number.
Setget perl method. Argument is string.
Setget perl method. Argument is url. Not used when creating a new category.
Setget perl method. Argument is url. Not used when creating new category.
This is buggy, you can create a new category with a description, but you can't fetch it. See WordPress::XMLRPC getCategory() for more. So, the description if set *is* stored in your blog, but won't be fetched.
Returns string 'Category'.
Optional argument is an id or categoryName string. Returns hashref, (but loads data into object)..
my $cat = new WordPress::API::Category({ proxy => 'http://site.com/xmlrpc.php', username => 'jimmy', password => 'jimmyspass', }); $cat->id(5); $cat->load or die( $cat->errstr ); print $cat->rssUrl;
load() is called by save().
Unfortunately wordpress' xmlrpc command can't edit categories. But you can use save to create a new category.
You cannot save changes to a category, you can only view existing categories and create new ones. If you load() a category you cannot save() it. You can save() and then view its url, etc, though.
$cat->categoryName('House Inspections'); $cat->description('hi this is a description'); # will not show up after save, wordpress bug my $id = $cat->save; # or $cat->save; my $id = $cat->id; # now you can make a new post and set the parent to that category.. # new WordPress::API::Post ....
In development.
WordPress::API
To install WordPress::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WordPress::API
CPAN shell
perl -MCPAN -e shell install WordPress::API
For more information on module installation, please visit the detailed CPAN module installation guide.