Add unique variable to walker class start_lvl
-
Hey everyone,
I need to add unique identifiers to every level of the wp_list_categories list tree.
In situations with child categories, they are always listed as
<ul class="children">
I would like to change the start_lvl function in the Walker Class (Walker_Category) from:
function start_lvl(&$output, $depth, $args) { if ( 'list' != $args['style'] ) return; $indent = str_repeat("\t", $depth); $output .= "$indent<ul class='children'>\n"; }
To:
function start_lvl(&$output, $depth, $args) { if ( 'list' != $args['style'] ) return; $indent = str_repeat("\t", $depth); $output .= "$indent<ul id='children-$UNIQUE_ID' class='children'>\n"; }
This can be a category ID, or something similar, but each UL needs to have a fully unique ID attached to it.
The only variable I can get in there to parse is $depth, but that created non-unique IDs if there are multiple top-level cats, etc.
Any ideas?
- The topic ‘Add unique variable to walker class start_lvl’ is closed to new replies.