I'm trying to check the value of a field on my content type that is a list of taxonomy terms to see if it matches a specific taxonomy term, then if it does match, echo the description field of the taxonomy term I checked. Else, if it does not match, then nothing is to be printed out.

Here is the code I've been experimenting with, but thus far have been unsuccessful getting to work properly:

if ( isset($facil->field_facility_type['und']) && 
 $facil->field_facility_type['und'][0]['value'] == "Hospital")) {
foreach ($facil->field_facility_type['und'] as $description ) {
    echo '<span><p> Say something wild and crazy!</p>'.$description["value"].'</span>';
    echo '<br/>';


I'm confused on how to get it to check the value of the field of taxonomy terms, of which the specific one I'm trying to target for this piece is one of about 15 different terms.

1 Answer 1


So, here's what we ended up with:

$fterm = taxonomy_term_load( (int)$facil->field_facility_type['und'][0]['tid'] );
        $fname = $fterm->name;
        $description = $fterm->description;

        if( $fname == 'Hospital' ) {
            if( !empty($description) ) echo '<div>' . $description . '</div>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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