[wp-trac] [WordPress Trac] #4821: wp_list_categories() messes up
the current category
WordPress Trac
wp-trac at lists.automattic.com
Sun Aug 26 20:15:21 GMT 2007
#4821: wp_list_categories() messes up the current category
---------------------+------------------------------------------------------
Reporter: xtc62 | Owner: anonymous
Type: defect | Status: new
Priority: low | Milestone: 2.4 (next)
Component: General | Version: 2.1.3
Severity: trivial | Keywords:
---------------------+------------------------------------------------------
I tried on my blog to list the latest 5 posts from some of my categories
so I used a "second loop" like this:
{{{
<?php query_posts('cat=5&showposts=5');
}}}
and then the usual loop routine with
{{{
<?php while( have_posts() ) : the_post(); ?>
...
<?php endwhile; ?>
}}}
After this I wanted to list all of my categories using the
wp_list_categories() but found out that even if I was under category with
ID=6(for example) the category with ID=5 was still the one classed with
"current-cat". I'm shure it has to do something with that "second loop"
thing since the category that is being marked as current is the last for
which I've called the loop for and if I call the wp_list_categories()
before the second loops it works all right.
I'm not sure if this is a bug or a feature but if it's the former this I
think would be the best place to start fixing it:
{{{
//wp-includes/category-template.php around line 245
if ( is_category() )
$r['current_category'] = $wp_query->get_queried_object_id();
}}}
The logic in Walker_Category::start_el() seems correct.
--
Ticket URL: <http://trac.wordpress.org/ticket/4821>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list