Hi I am trying to use ternary operators with WordPress condtionals, using the code below, but it’s giving me a PHP error, what am I doing wrong?

echo is_home() : '1' ? '0';

2 Answers
2

Syntax is wrong you need to phrase it like so:

condition ? TRUE : FALSE

so change your code to :

echo is_home() ?  '1' : '0';

Leave a Reply

Your email address will not be published. Required fields are marked *