Skip to content

Instantly share code, notes, and snippets.

@bejes
Forked from davemac/gist:3507619
Created August 29, 2012 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bejes/3507776 to your computer and use it in GitHub Desktop.
Save bejes/3507776 to your computer and use it in GitHub Desktop.
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