Skip to content

Instantly share code, notes, and snippets.

@davemac
Created August 29, 2012 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davemac/3507619 to your computer and use it in GitHub Desktop.
Save davemac/3507619 to your computer and use it in GitHub Desktop.
function get_deep_child_category( $categories )
{
$categories = get_the_category();
$maxId = 0;
$maxKey = 0;
foreach ( $categories as $key => $value )
{
if ( $value->parent > $maxId )
{
$maxId = $value->term_id;
$maxKey = $key;
}
}
return $categories[$maxKey];
}
function display_deep_child_category(){
$deepChild = get_deep_child_category( $categories );
$displayDeepChild = $deepChild->term_id;
echo $displayDeepChild;
}
@bejes
Copy link

bejes commented Aug 29, 2012

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;
$maxKey = $key;
}
}

return  $categories[$maxKey]->term_id;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment