Title: Whats wrong with this code?
Last modified: August 19, 2016

---

# Whats wrong with this code?

 *  Resolved [threevisual](https://wordpress.org/support/users/threevisual/)
 * (@threevisual)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/)
 * I’m not too good with PHP… can someone please tell me what I’ve done wrong with
   the following as it’s returning an error to me and I can’t figure it out….
 * `<?php if (in_category('8')) {echo '<strong>Select your rating:</strong> <?php
   if(function_exists('the_ratings')) { the_ratings(); }?> ';} ?>`
 * Thanks
 * Edit: the error being returned is:
 * Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/
   wired/public_html/wp-content/themes/wired/comments.php on line 90

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Evita](https://wordpress.org/support/users/evita/)
 * (@evita)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-820747)
 * I think you are missing the second part:
    if in category 8 – do something else–
   do somehting other or nothing
 * Read about the usage of [Conditional Tags](http://codex.wordpress.org/Conditional_Tags)
   on WordPress codex.
 *  Thread Starter [threevisual](https://wordpress.org/support/users/threevisual/)
 * (@threevisual)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-820758)
 * thanks evita… although i’m still a little confused on how to add the else tag,
   it’s still throwing the error at me. I really should try and learn the basics
   of PHP.
 *  [Evita](https://wordpress.org/support/users/evita/)
 * (@evita)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-820764)
 * Maybe this will help you:
 *     ```
       <?php if ( in_category(xx) ) { ?>
       DO SOMETHING
       <?php } else { ?>
       DO SOMETHING OTHER OR LEAVE IT BLANK
       <?php } ?>
       ```
   
 *  Thread Starter [threevisual](https://wordpress.org/support/users/threevisual/)
 * (@threevisual)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-820787)
 * excellent! thank you!
    I think I have it now, have no idea what I was doing before
   but it wasn’t working.
 *  Thread Starter [threevisual](https://wordpress.org/support/users/threevisual/)
 * (@threevisual)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-821064)
 * Is there anyway to modify this so its if in SUB category of x?
 *  Thread Starter [threevisual](https://wordpress.org/support/users/threevisual/)
 * (@threevisual)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-821065)
 * OK, I’ve had a look around and found that in_category doesn’t pick up sub-categories
   so you have to list them manually. For anyone else trying to do something similar
   here’s how you do it:
 *     ```
       <?php if ( in_category(2) || in_category (2) || in_category (3) || in_category (4) ) { ?>
       Content
       <?php } else { ?>
       Content
       <?php } ?>
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Whats wrong with this code?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [threevisual](https://wordpress.org/support/users/threevisual/)
 * Last activity: [17 years, 8 months ago](https://wordpress.org/support/topic/whats-wrong-with-this-code-1/#post-821065)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
