Forums

in_category not working (2 posts)

  1. element94_2007
    Member
    Posted 1 year ago #

    Hello everyone.
    I have the fowlloing code on my sidebar:

    <?php
    if (is_home())
    {?>
    some script here
    <?}
    elseif (in_category('369'))
    {?>
    some script here
    <?}
    
    else
    { ?>
    some script here
    <?}
    ?>

    For some reason in_category won't work. But if i change it to is_category then i see the script working on the category page .
    Any thoughts?

  2. lexhair
    Member
    Posted 1 year ago #

    Take a look at the codex. in_category usually runs in The Loop and the sidebar isn't in The Loop. is_category is a conditional tag which generally is placed outside The Loop.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.