• Resolved thebigtine

    (@josephbydesign)


    Hi,

    I am trying to write a function that checks what category the current post is in and if it equals a certain category, in my case ‘2’, then it would return one thing if not, it would return nothing. here is my code so far:

    if (get_the_category() == ‘2’) {
    // Leave blank to Do Nothing
    } else {
    // Do Something
    }

    I know this is probably ways off what it should be. I know get_the_category() returns an array, so that is probably my first problem, but if I do echo 'cat:' . get_the_category(); It doesn’t echo anything.

    Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘if post is in a certain catigory’ is closed to new replies.