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
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 on WordPress codex.
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.
Maybe this will help you:
<?php if ( in_category(xx) ) { ?>
DO SOMETHING
<?php } else { ?>
DO SOMETHING OTHER OR LEAVE IT BLANK
<?php } ?>
excellent! thank you!
I think I have it now, have no idea what I was doing before but it wasn't working.
Is there anyway to modify this so its if in SUB category of x?
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 } ?>