WordPress.org

Ready to get started?Download WordPress

Forums

How To Isolate category in Widgets (1 post)

  1. hotinthenews
    Member
    Posted 1 year ago #

    Hello,

    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()) : ?>
    <?php
    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.

    Thanks

    Lode

Topic Closed

This topic has been closed to new replies.

About this Topic