Support » Fixing WordPress » Parent category identification problem

  • I want to display a snippet when post is in specific categories.
    I have categories A, B , C, D and want to display “How r u” when posts belong to Categories A and B. Also, if the post belongs to sub-categories in A and B.

    I used the code

    if ( in_category(array('A,'B')))
    echo "How r u";

    It works fine but if the post is in sub-category of A or B it does not work. I do not wish to hardcode the sub-category names as I might add few more sub-categories.
    Is there a way I can check direct parent and display what I want.

  • The topic ‘Parent category identification problem’ is closed to new replies.