Answer the question
In order to leave comments, you need to log in
How to get the bottom level taxonomy on a post page?
category>1category
I need to get 1 category on a post page.
Tried through get_the_terms( get_the_id(), 'category )[1]->term_taxonomy_id;
But on some pages it is at index 0.
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/function.array-reverse.php
$terms = get_the_terms( get_the_id(), 'category' );
$terms = array_reverse( $terms );
echo $terms[0]->term_taxonomy_id;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question