WordPress.org

Ready to get started?Download WordPress

Forums

custom taxonomy array and loop through the values (1 post)

  1. betzy
    Member
    Posted 3 years ago #

    i have this function in my function.php

    // get the custom taxonomy array and loop through the values
    function jr_get_custom_taxonomy($post_id, $tax_name, $tax_class) {
        $tax_array = get_terms( $tax_name, array( 'hide_empty' => '0' ) );
        if ($tax_array && sizeof($tax_array) > 0) {
            foreach ($tax_array as $tax_val) {
                if ( is_object_in_term( $post_id, $tax_name, array( $tax_val->term_id ) ) ) {
                    echo '<span class="'.$tax_class . ' '. $tax_val->slug.'">'.$tax_val->name.'</span>';
                    break;
                }
            }
        }
    }

    and in index.php i have this

    <?php jr_get_custom_taxonomy($post->ID, 'job_type', 'jtype'); ?>

    ok this display the job type with diferent colors
    for two days i am trying to modify this to display images on specific job types instead of job type
    i don-t know any php but i was testing this

    <?php if ( $job_type_slug ='part-time') {
    	echo ('test 1');
    } else {
    	echo ('test 2');
    }
    ?>

    but no matter what i put on $job_type_slug it allways display "test 1" :((

Topic Closed

This topic has been closed to new replies.

About this Topic