mores,
looks like “high noon” for dissolving the problems one can see over meanwhile 2 years or so while reading the “decoupling” and “consult hierarchy” comments in the php core.
the whole mess with the category-template is fermenting since the devolopment focuses on tags and widgets.
i have to find a solution for this within the next few days and will post this here. but smells like it will be a greasy hack. stay tuned!
Perhaps the Codex does not display the parameter that the function wp_list_categories currently can handle.
I just stumbled about the parameter current_category.
You just have to set the current Category-Id for this.
Try this in your Category-Template in your Templatefolder:
<?php
$catsy = get_the_category();
$myCat = $catsy[0]->cat_ID;
wp_list_categories('hierarchical=1&use_desc_for_title=0&orderby=name&title_li=&depth=3¤t_category='.$myCat);
?>
Hope this helps. For my purposes it is working, though there could be more Functionality with collapsing Flaps. May be in the future…
Thread Starter
mores
(@mores)
AWESOME !!
That’s exactly what I needed, and it works like a charm. It’s actually in my header.php.
Now, since I use a “home” before and a “wp_list_pages” after the wp_list_categories tag, I got weird results when I was on a page or on home.
Here’s my addition to your code:
<?php
if (!is_page() && !is_home()){
$catsy = get_the_category();
$myCat = $catsy[0]->cat_ID;
$currentcategory = '¤t_category='.$myCat;
}
wp_list_categories('hierarchical=1&use_desc_for_title=0&exclude=12&depth=1&orderby=id&title_li='.$currentcategory);
?>
It checks if the page we’re on is NOT a Page and is also NOT home. In this case, it adds the current_category bit to the list_categories tag.
Thank you so much warmbeer!
mores,
for now 😉 let’s see what will happen with WP-Version 2.7.
Glad to help You!
Royal Bavarian Regards!
This is exactly what I was looking for!
I have my categories appearing in the footer like this:
<?php if (is_home() || is_category() || is_single()) { ?>
<ul class="categories">
<?php wp_list_categories('title_li=&depth=1'); ?>
</ul>
<?php } ?>
so my question is: where exactly do I put the code you have provided?
2.7 is a great update, but it doesn’t seem to give more love to categories.
how would I have to alter warmbeer’s code to allow for a .current-cat-parent
class?
warmbeer you’re awesome, cheers
transalpin
I’d like to know this too. Had any luck?
your solution doesn’t work properly on deeper levels ;/ (I tried when [0] from array is on 3rd level deep). any ideas?
I didn’t get this the first time round.
Warmbeer… thank you so much!
how do you fix the issue with tag cloud? When click to a tag cloud, both home item and others items are highlight.
Looks like current_category is now listed as a parameter of wp_list_categories()
Btw thanks, Warmbeer, this is the solution I was looking for with a similar problem.
The problem I’m working out is that:
<?php
$catsy = get_the_category();
$myCat = $catsy[0]->cat_ID
?>
$catsy[0] is not always what you’re looking for. For example sometimes is a subcategory when I’m browsing a parent, and sometimes it doesn’t really show up.
A partial solution is to replace $catsy[0] with $catsy
<?php
$catsy = get_the_category();
$myCat = $catsy->cat_ID
?>
This works properly with child categories and if a parent category is clicked then the parent and all the children are highlighted (that is show class=”current-cat”.
In the end I may want the highlighting to only be on precisely what single_cat_title(] would display…. however having the parent and all the children highlighted when browsing a parent could actually be a feature……
(I do change the order of the categories and subcategories from the defualt, so maybe that’s why $catsy[0] behaves badly for me.)
I stumbled upon this and I just want to say thank you! What warmbeer posted worked perfectly!