• Resolved lowlight

    (@lowlight)


    I am using

    if (in_category('19'))

    to display a line of text in the footer of posts that are only in that category.

    However, the footer is showing up on the index too!

    How can I remove that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The in_category template tag can only be used in The Loop.

    Are you talking about displaying that in your footer when you display a single post with a Template such as single.php?

    Or are you talking about when you are displaying the posts in a given category such as a Category Archive?

    Thread Starter lowlight

    (@lowlight)

    I put that in the footer.php, so it echos a string of text only to be shown at the bottom of single.php, only for posts that belong to category 19. It works for the most part, except index.php also displays it.

    Is there a better way to display a line of text in footer.php in single.php, only for certain categories?

    you need is_single() && in_category('19')

    this is because in_category will evaluate true based on the (first or) last post in your loop. so adding the is_single condition will help

    Thread Starter lowlight

    (@lowlight)

    Perfect, thanks

    taghaboy

    (@taghaboy)

    thanks a lot SIR alanft, you help me a lot,
    and this is my post :
    http://wordpress.org/support/topic/259606?replies=8
    mybe it can help some one who search for global category.
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘if (in_category(”)) is showing up on index too’ is closed to new replies.