Title: Help with Walker Class
Last modified: August 20, 2016

---

# Help with Walker Class

 *  [joemastro](https://wordpress.org/support/users/joemastro/)
 * (@joemastro)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/help-with-walker-class/)
 * Howdy. First time messing with the Walker Class, and I can’t get pst a problem.
   Documentation is found wanting for a newbie.
 * I have a custom post type. In it is a custom taxonomy. I want to change the output
   of wp_list_categories to get away from lists.
 * Here is my code on the page:
 *     ```
       $post_terms=wp_get_post_terms( $post->ID, 'region');
       foreach($post_terms as $q){
           $list_terms .= $q->term_id.', ';
       }
       $to_include = clc_shave_string($list_terms,2); (this just knocks the extra "," and whitespace off the string)
       $args = array(
         'taxonomy'     => 'region',
         'orderby'      => 'name',
         'hierarchical' => 1,
           'include' => $to_include,
           'title_li' => '',
          'walker' => new My_Region_Walker(),
       );
       wp_list_categories( $args );
       ```
   
 * And my Walker:
 *     ```
       class My_Region_Walker extends Walker {
           var $tree_type = 'category';
           var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
           function start_lvl( &$output, $depth = 0, $args = array() ) {
               $indent = str_repeat("<br />\t", $depth);
       	}
           function end_lvl( &$output, $depth = 0, $args = array() ) {
       	$indent = str_repeat("\t", $depth);
       	$output .= "$indent<br />\n";
       	}
   
           function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
       	extract($args);
   
       	$cat_name = esc_attr( $category->name );
       	$cat_name = apply_filters( 'list_cats', $cat_name, $category );
       	$link = '<a href="' . esc_url( get_term_link($category) ) . '" ';
       	if ( $use_desc_for_title == 0 || empty($category->description) )
                   $link .= 'title="' . esc_attr( sprintf(__( 'View all cruises filed under %s' ), $cat_name) ) . '"';
       	else
                   $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
       	$link .= '>';
       	$link .= $cat_name . '</a>';
   
               if ( !empty($show_count) )
                   $link .= ' (' . intval($category->count) . ')';
   
       		/*if ( 'list' == $args['style'] ) {
       			$output .= "\t<li";
       			$class = 'cat-item cat-item-' . $category->term_id;
       			if ( !empty($current_category) ) {
       				$_current_category = get_term( $current_category, $category->taxonomy );
       				if ( $category->term_id == $current_category )
       					$class .=  ' current-cat';
       				elseif ( $category->term_id == $_current_category->parent )
       					$class .=  ' current-cat-parent';
       			}
       			$output .=  ' class="' . $class . '"';
       			$output .= ">$link\n";
       		} else {
       			$output .= "\t$link<br />\n";
       		}*/
               $output .= $link."\n";
           }
   
           function end_el( &$output, $page, $depth = 0, $args = array() ) {
           }
       }
       ```
   
 * My problem is that the categories won’t line break after a parent with no child.
   Instead of:
    Caribbean Europe Mediterranean Greek Isles North America Alaska 
   World Asia Japan
 * I get:
    Caribbean Europe Mediterranean Greek Isles North America Alaska World
   Asia Japan
 * Edited to add tags

The topic ‘Help with Walker Class’ is closed to new replies.

## Tags

 * [Walker](https://wordpress.org/support/topic-tag/walker/)
 * [wp_list_categories()](https://wordpress.org/support/topic-tag/wp_list_categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [joemastro](https://wordpress.org/support/users/joemastro/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/help-with-walker-class/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
