If Custom Taxonomy

I have a custom taxonomy set for my posts, called $type. I would like to echo within the standard WordPress while loop, if the $type == ‘roast.

<?php $number = 1; ?>
<!– the loop –>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<?php $type = get_the_term_list( $post->ID, ‘type’, ” );
echo $type;
if ($type == “roast”) { ?>
<li><?php echo $number . ‘. ‘; $number++;?>
<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
<span><?php echo get_the_term_list( $post->ID, ‘rating’, ” ); ?></span>
<span><?php echo get_the_term_list( $post->ID, ‘price’, ” ); ?></span>
</li>
<?php }
if (in_array(‘roast’, $type)) { echo “hello”; }
?>

I first echo out $type, as a test, and this does echo ‘roast’.

Yet my if statement, and later attempt at using in_array, do not echo as expected.

Can anyone kindly advise what I am doing wrong?

Kind regards
James

Read more here:: If Custom Taxonomy

Leave a Reply

Your email address will not be published. Required fields are marked *