WordPress.org

Ready to get started?Download WordPress

Forums

[closed] PHP if statements (2 posts)

  1. damian.smith
    Member
    Posted 1 year ago #

    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>";
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.