I'm using get_the_term_list on an archive page which currently outputs all categories that a post is in with links.

My question: Is it possible to only display the last child category, not any parents or grandparents?

Thios is what I have that outputs all:

<?php if( get_the_terms(get_the_ID(),'event-category') ){ 
    echo get_the_term_list( get_the_ID(),'event-category', '', ', ', '' ); 
} ?>

Nevermind. It turns out that this doesn’t list the parent categories anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.