Support » Fixing WordPress » How To Isolate category in Widgets

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



  • The topic ‘How To Isolate category in Widgets’ is closed to new replies.