WordPress get_nested_categories() Bug [en]

Some code I produced while trying to fix and already fixed Wordpress bug (in get_nested_categories()).

I bumped into my first really annoying WordPress bug today. The function get_nested_categories(), which is used to display the different categories available in the admin screens, wrongly assumes in 1.2 that people create their parent categories before their children (and that the latter have a higher ID than the former).

This has been fixed in the CVS. However, as there have been changes since 1.2 in CVS, you need to copy the code provided on the bug report page. Take the first function from the “Additional Information” part, and the second one from the “Bug Notes” section.

As I didn’t know about the web-based CVS, I started trying to fix the bug myself. It’s almost finished but doesn’t work yet (just a little bug to track down), and it only uses one MySQL query, whereas the fix presented above can end up using lots, if you have a complicated hierarchical category structure like mine. You’re welcome to have a go at my code — let me know if you find the problem!

Next time I meet a bug, I’ll check in CVS first to make sure it isn’t already half dead.

Leave a Reply

Your email address will not be published. Required fields are marked *