[wp-trac] [WordPress Trac] #14846: in_category returning true when last post is from specified category

WordPress Trac wp-trac at lists.automattic.com
Sun Sep 12 16:18:09 UTC 2010


#14846: in_category returning true when last post is from specified category
-----------------------------+----------------------------------------------
 Reporter:  enrique-ramirez  |       Owner:                 
     Type:  defect (bug)     |      Status:  new            
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:  3.0.1          
 Severity:  major            |    Keywords:                 
-----------------------------+----------------------------------------------

Comment(by enrique-ramirez):

 Ok, not quite.

 It IS true the above string returns a string of bool(false)'s, but I need
 this outside each post, not once per post.

 Say, for example, I have this code:


 {{{
     <h1><?php if ( in_category('8') ) { ?>Category 8<?php } else {
 ?>Blog<?php } ?></h1>

     <?php query_posts('&cat=-3,-8'); ?>
         <?php if (have_posts()) : ?>

             <ol>

             <?php while (have_posts()) : the_post(); ?>
             <li>... </li>
             <?php endwhile; ?>

         </ol>
     <?php endif; wp_reset_query(); ?>
 }}}

 I don't need an <h1> per post, since this is the "section" title.

 Once again, this is just an example. I'm actually using this to get
 different sidebars per section in my sidebar.php file, but it gives you
 the idea I need the true or false value outside the actual post.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14846#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list