How To Isolate category in Widgets (1 post)

  1. hotinthenews
    Posted 3 years ago #


    I wrote a tiny php program that all it does is check what category the article is under. In my single.php file the code works as intended but not in a text widget which I post as a sidebar next to the article.

    (I use the extended text widget module that accepts PHP code).

    Here's my code:

    <?php if(have_posts()) : ?>
    if ( in_category('api') ) {
    --- then do something ---;
    } else {
    --- then do something else ---;
    <?php endif; ?>

    In the text widget it seems to automatically go to the } else { option even though the first condition is met.

    Any suggestions would be greatly appreciated.



Topic Closed

This topic has been closed to new replies.

About this Topic