Title: PHP if statements
Last modified: August 20, 2016

---

# PHP if statements

 *  [damian.smith](https://wordpress.org/support/users/damiansmith/)
 * (@damiansmith)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/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)

 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/php-if-statements/#post-3270197)
 * Don’t multipost, as per the [Forum Rules.](http://codex.wordpress.org/Forum_Welcome)
 * Dupe: [http://wordpress.org/support/topic/calling-certain-product_cat?replies=3](http://wordpress.org/support/topic/calling-certain-product_cat?replies=3)

Viewing 1 replies (of 1 total)

The topic ‘PHP if statements’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/php-if-statements/#post-3270197)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
