Created
August 29, 2012 06:51
-
-
Save davemac/3507619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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;
}
}
}