Leo Charre > WordPress-API-1.10 > WordPress::API::Category

Download:
WordPress-API-1.10.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

WordPress::API::Category

SYNOPSIS ^

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

How to id the category ^

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);

METHODS ^

category setget methods

categoryId()

Setget perl method. Argument is number.

categoryName()

Setget perl method. Argument is string.

rssUrl()

Setget perl method. Argument is url. Not used when creating a new category.

parentId()

Setget perl method. Argument is number.

htmlUrl()

Setget perl method. Argument is url. Not used when creating new category.

description()

Setget perl method. Argument is string.

CAVEAT

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.

object_type()

Returns string 'Category'.

load()

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().

save()

Unfortunately wordpress' xmlrpc command can't edit categories. But you can use save to create a new category.

MAKING 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 ....

CAVEATS ^

In development.

SEE ALSO ^

WordPress::API

syntax highlighting: