Created
September 1, 2013 01:14
-
-
Save lgedeon/6401708 to your computer and use it in GitHub Desktop.
clever way to find a term when you don't know what you have been given
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
} elseif ( isset ( $item->taxonomy ) && isset( $item->term ) ) { | |
if ( ( is_int( $item->term ) && $term = get_term_by( 'id', $item->term, $item->taxonomy ) ) | |
|| ( $term = get_term_by( 'name', $item->term, $item->taxonomy ) ) | |
|| ( $term = get_term_by( 'slug', $item->term, $item->taxonomy ) ) ) { | |
$item_array['menu-item-type'] = 'taxonomy'; | |
$item_array['menu-item-object'] = $term->taxonomy; | |
$item_array['menu-item-object-id'] = $term->term_id; | |
$item_array['menu-item-title'] = ( $item_array['menu-item-title'] ) ?: $term->name; | |
} else { | |
continue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment