| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class Walker_Simple_Example extends Walker {
|
|---|
| 4 | var $db_fields = array('parent' => 'parent', 'id' => 'term_id');
|
|---|
| 5 |
|
|---|
| 6 | function start_lvl(&$output, $depth=0, $args=array()) {
|
|---|
| 7 | $output .= "\n<ul>\n";
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | function end_lvl(&$output, $depth=0, $args=array()) {
|
|---|
| 11 | $output .= "</ul>\n";
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | function start_el(&$output, $item, $depth=0, $args=array()) {
|
|---|
| 15 | $output .= "<li>".esc_attr($item->name);
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | function end_el(&$output, $item, $depth=0, $args=array()) {
|
|---|
| 19 | $output .= "</li>\n";
|
|---|
| 20 | }
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | $elements = get_categories();
|
|---|
| 24 | $walker = new Walker_Simple_Example;
|
|---|
| 25 | echo $walker->walk($elements, 0);
|
|---|