get_the_term_list()
returns a string of HTML for the list of taxonomy terms on the given post. Without giving values in the optional arguments it would look like this:
<a href="http://example.com/type/roast/" rel="tag">Roast</a> <a href="http://example.com/type/type2/" rel="tag">Type 2</a>
So $type == 'roast'
would not be true because the value isn’t anything close to 'roast'
.
Even if it returned an array like array( 'roast' )
it wouldn’t be true because 'roast'
does not equal array( 'roast' )
.
If you want to check if a post has a given term in a taxonomy, use the has_term()
function:
if ( has_term( 'roast', 'type' ) ) {
}