WordPress.org

Support

Support » How-To and Troubleshooting » PHP if statements

PHP if statements

  • Hey guys,

    I have posted this into the woocommerce section but not getting any responses.
    Basically I have the below code, which doesn’t seem to be working.

    It is basically trying to find out the current product category and then depending on what it is display “this”

    Is there something wrong with my code?

    <?php
    $terms = get_the_terms( $post->ID, 'product_cat' );
    $term = current($terms);
    if ($term == "safety-range") {
    echo "<h1>hello</h1>";
    }
    ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘PHP if statements’ is closed to new replies.