Created
April 2, 2012 22:15
-
-
Save rosschapman/2287584 to your computer and use it in GitHub Desktop.
Way to get last term of get_terms array in #wordpress
This file contains 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
$terms = get_the_terms($post->ID, $taxonomy); | |
end($terms); | |
$term_id = key($terms); | |
$term = get_term($term_id,$taxonomy); | |
echo $term->name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For WordPress 4.7.3 get_the_terms() returns an array of WP_Term objects.