Skip to content

Instantly share code, notes, and snippets.

function get_deep_child_category()
{
$categories = get_the_category();
$maxId = 0;
$maxKey = 0;
foreach ( $categories as $key => $value )
{
if ( $value->parent > $maxId )
{
$maxId = $value->term_id;
@bejes
bejes / gist:1480933
Created December 15, 2011 12:28 — forked from davemac/gist:1480832
WordPress get the category parent slug and include in body_class
<?php
if (is_single() || is_category()) {
$category = get_the_category();
$nice_name=array();
foreach($category as $c)
{
$parent = $c->category_parent;
$parent_cat =get_category($parent);
$nice_name[]= $parent_cat->category_nicename;