#4821 closed defect (bug) (invalid)
wp_list_categories() messes up the current category
Reported by: | xtc62 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | trivial | Version: | 2.2.2 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (4)
#2
@
17 years ago
- Version changed from 2.1.3 to 2.2.2
I noticed while posting that I don't have the latest version so I upgraded but I forgot to change the "version" field to 2.2.2. Anyway, the bug is present in version 2.2.2 too( again, if indeed it's a bug ).
xtc62, please test and report bugs verses the current version, which is currently 2.2.2 , even better there will be a 2.3 beta this week. Thank you.