Currently viewed item does not display properly with custom taxonomies
-
Hi there,
Thanks for the great plugin. Here’s an issue I’ve found with a possible fix.
I’m using this to display terms from a custom post type that has a custom taxonomy associated with it.
If you use regular categories, when you click an item to show the archive, it expands the current item when the archive loads.
If you use a custom taxonomy, the styling is broken, and the current parent item doesn’t expand.
I tracked this down to the fact that the “self” and “parent” classes are not added to the li element correctly. And I think this is because of this code in the list_categories function in collapscatlist.php:
if (is_category()) { $thisCatID = $wp_query->get_queried_object_id(); $thisCat = get_term($thisCatID, $taxonomy); checkCurrentCat($thisCat,$categories); }
It looks like you check for is_single() and is_category(), but you don’t check for custom taxonomies.
I’ve fixed this by changing line 579 so that you have:
if (is_tax()) { $thisCatID = $wp_query->get_queried_object_id(); $thisCat = get_term($thisCatID, $taxonomy); checkCurrentCat($thisCat,$categories); }
I also think the styles could use a tweak. Currently when a parent category is displayed (i.e. we are looking at its archive), all it’s children are highlighted in bold. When actually I think you just want the current category, and maybe its parent in bold.
So I changed
{ID} li.collapsing.categories.self a {font-weight:bold}
to
{ID} li.collapsing.categories.self > a {font-weight:bold} {ID} li.collapsing.categories.parent > a {font-weight:bold}
in the collapsCatStyles.php
Are these changes right do you think? Could they be added to the plugin?
Thanks
- The topic ‘Currently viewed item does not display properly with custom taxonomies’ is closed to new replies.