Help with in_category function outside of the loop

Discussion in 'PHP' started by Soamelt, Dec 17, 2008.

  1. #1
    Help please! I'm trying to use the in_category function in my wordpress blog's sidebar so that certain things show up in the sidebar to correspond with the categories. I read through the wordpress guide: http://codex.wordpress.org/Template_Tags/in_category and my code looks like:
    
    <?php
    if ( have_posts() ) { the_post(); rewind_posts(); }
    
    if ( in_category('7') ) {
    ########category specific code######
    
    } elseif ( in_category('25') ) {
    ########category specific code######
    
    } else {
    ########category specific code######
    }
    
    ?>
    
    PHP:
    all this does is make my whole sidebar fail.
     
    Soamelt, Dec 17, 2008 IP