First: you’re using =
which assigns a value; use ==
to compare the values (or ===
to compare strictly, ie, match both the value and the type).
Second: Your code snippet shows that you’ve mismatched the "
s in the array, which should probably result in a PHP fatal error. I’m assuming that’s an error in the posted code but not in your production code.
Finally: your comparison will only work if $product_tag->slug
matches the entire array shown. If you only want to check if $product_tag->slug
matches one of the items in the array, you’ll need to use in_array()
.
eg:
if ( in_array( $product_tag->slug, ["TAG1", "TAG2", "TAG3"] ) ) {
$img_url = get_option( 'z_taxonomy_image' . $product_tag->term_id );
$this->format_setting( $product_tag->name, $img_url, $product_tag->term_id );
}