Nikhil_K_R
Nikhil_K_R

Reputation: 2373

Load Fishpig Blog category collection by Id and get its details

I wanted to load a fishpig category collection by Id and retrieve its details.
Have used this code.

$main_category_col = Mage::getResourceModel('wordpress/post_category_collection')->load(6);
foreach($main_category_col as $main_category_col_obj)
    {
        $category_name = $main_category_col_obj->getName();         
    }

Please help.

Upvotes: 0

Views: 2636

Answers (1)

Nikhil_K_R
Nikhil_K_R

Reputation: 2373

We can't load a collection by an id; a collection is multiple items where as an ID belongs to a single item. If you have the category and want to load it, use the following code:

$category = Mage::getModel('wordpress/post_category')->load($categoryId);

If you then want to display the category name you can use:

echo $category->getName();

Courtesy : Ben Tideswell (From Fishpig)

Upvotes: 1

Related Questions