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';
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';
Syntax is wrong you need to phrase it like so:
condition ? TRUE : FALSE
so change your code to :
echo is_home() ? '1' : '0';