I'm templating a single.php and I want to display something like 'Destination: Paris' or 'Destinations: Paris, London'. So I'd like to check if the taxonomy 'Destination' has more than one item in order to output 'Destination' if tax has only one item and 'Destinations' if tax has more than one item. Thanks for any help you guys might provide!

  • You mean “if current post has more than one term in given taxonomy”, right? May 29, 2018 at 16:58
  • Yes, Krzysiek. That's precisely what I mean.
    – Emmanuel
    May 29, 2018 at 21:23
  • ok, So my answer should be helpful :) May 29, 2018 at 21:24

1 Answer 1


And if you want to check if current post has more than one term in given taxonomy (it's not very clear in your question and this version makes much more sense for me...), then function get_the_terms will come handy:

$terms = get_the_terms( $post, $taxonomy );
echo ( count($terms) > 1 ) ? 'Destinations' : 'Destination';
  • 1
    This code works fine for me and I understand it. I'll use it. Thank you very much, hasta luego.
    – Emmanuel
    May 29, 2018 at 21:33
  • @Emmanuel No problem. Just remember to mark answer as correct one if it was helpful ;) May 29, 2018 at 21:36
  • Don't get me wrong, your answer is useful and correct, but I can't mark it because 'This action requires 15 reputation.' and I have no reputation (I'm blushing).
    – Emmanuel
    May 29, 2018 at 21:58
  • @Emmanuel wow, I forgot how it was to be a new member :) No problem. You can always upvote it, I guess... nevertheless, I’m glad it helped you :) May 29, 2018 at 22:10

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.