-
Get the parent category of post in wordpress
get current post id
$id = get_the_ID();
echo $id;
get current post parent category slug
$category = get_the_category();
$category_parent_id = $category[0]->category_parent;
if ( $category_parent_id != 0 ) {
$category_parent = get_term( $category_parent_id, ‘category’ );
$cat_parent_slug = $category_parent->slug;
} else {
$cat_parent _slug = $category[0]->slug;
} -
magento 1.9 get parent category of category & attribute set name
get the name of parent category
$abc = Mage::registry(‘current_category’)->getName();
$_category = Mage::getResourceModel(‘catalog/category_collection’)
->addFieldToFilter(‘name’, $abc)
->getFirstItem();
$categoryId = $_category->getId();
$categoryle = Mage::getModel(‘catalog/category’)->load($categoryId);
$catnames = array();
foreach ($categoryle->getParentCategories() as $parent) {
$catnames[] = $parent->getName();
}Get attribute set name of the product by id
$productle = Mage::registry(‘current_product’);
$prodid = $productle->getId();
$attributeSetModel = Mage::getModel(“eav/entity_attribute_set”);
$sess_product = Mage::getModel(‘catalog/product’)->load($prodid);
$attributeSetModel->load($sess_product->getAttributeSetId());
$attributeSetName = $attributeSetModel->getAttributeSetName();