Ternary Operator not showing correct data + removing UI
-
I’m currently trying to use a ternary operator as I’m using echo.
I’m trying to check if a category ID equals the number 3, if it does, I would like it to create a new div containing an image.
This is the ternary operator i’m using which is inside a for loop:
`<p>’. wp_get_post_categories($recent[“ID”])[0] == “3” ? “yes” : “no”.'</p>Outputting just wp_get_post_categories($recent[“ID”])[0] gets me the number “3”, although “no” always seems to appear. I’ve tried using == 3 as well but still no luck.
In addition to this, everything inside the loop which generates UI styling disappears.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Ternary Operator not showing correct data + removing UI’ is closed to new replies.