• Resolved pmdci

    (@pmdci)


    Hi there,

    Is there a simple function that would return true or false if a post belongs to more than one term in a given taxonomy (or more than one category, since it is the same thing in WP 3).

    In human readable format, I was expecting to dosomething like this:

    If current post is in more has more than one city selected, returns true

    Perhaps something that would get the list of the taxonomy terms assigned to the post inan array. then if array contains more than one item, then returns true.

    Is this possible?

    Thanks in advance.
    P.

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    $terms = wp_get_post_terms( $post->ID , 'category', '');
    $count = count($terms);
    if ( $count > 1 ) {
      echo '<p>more than one category on this post</p>';
    }
    ?>
    Thread Starter pmdci

    (@pmdci)

    Hi MichaelH,

    This one worked like a charm! Thank you for your help!

    Cheers,
    P.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘checking if a post belong to multiple terms in a taxonomy/category’ is closed to new replies.