WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I haven't been able to find what I'm looking for and not sure how to approach it.

I'm using wp_list_categories to obviously list terms of a taxonomy. I'd like to add some text to the end of each item.

Example being:

  • taxonomy_term some_new_text
  • instead of
  • taxonomy_term
  • Here's the basic wp_list_categories that I'm using:

            'taxonomy' => 'locations',
            'orderby' => 'name',
            'style' => 'list',
            'order' => 'ASC',
            'title_li' => '',
            'number' => 25,


    Final code used to accomplish what I need

        $args = array(
            'taxonomy' => 'locations',
            'orderby' => 'name',
            'number' => 25,
        $categories = get_categories( $args );
        foreach ( $categories as $category ) {
            echo '<li>&nbsp;<a href="/locations/' . $category->slug . '">' . $category->name . ' ' . get_the_title() . '</a> |&nbsp;</li>';
    share|improve this question
    up vote 1 down vote accepted

    Use get_categories() (which returns an array of category objects rather than directly displaying them) instead of wp_list_categories, and loop through the results, outputting whatever you want.

    share|improve this answer
    Thanks! this worked great for what I needed. – NW Tech May 13 '13 at 15:18

    You can also use a custom walker for wp_list_categories(). That is a custom class extending Walker_Category. In that class you can change anything, including the list item ends.

    Sample class

    class Extended_Walker_Category extends Walker_Category
        function end_el( &$output, $page, $depth = 0, $args = array() ) {
            if ( 'list' != $args['style'] )
            $output .= " |&nbsp;</li>\n";


        array (
            'taxonomy' => 'locations',
            'orderby'  => 'name',
            'style'    => 'list',
            'order'    => 'ASC',
            'title_li' => '',
            'number'   => 25,
            'walker'   => new Extended_Walker_Category
    share|improve this answer

    Your Answer


    By posting your answer, you agree to the privacy policy and terms of service.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.