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

Im currently using <?php wp_list_categories('child_of=4&title_li='); ?> to echo out a list of my categories. I'm wondering how I could append some html (specifically an » to the end of each LI within the link.

See this screenshot for an example of what I'm trying to do:


share|improve this question

I think this is the cleanest and WordPressiest way to do it:

$menu_args = array(
    'child_of' => '4',
    'title_li' => '',
    'link_after' => '&raquo;',
share|improve this answer
Thanks! This was the answer I was looking for, just wasn't googling the right things! – nikibrown Feb 1 '11 at 15:53

Use the CSS :after pseudo-class.

I know people aren't big on psuedo-classes, but they work in all major browsers now. There's no reason not to use them.

share|improve this answer

Here is the method I would do using PHP str_replace:

$variable = wp_list_categories('child_of=4&echo=0&title_li=');
$variable = str_replace('</a>', ' »</a>', $variable);
echo $variable;
share|improve this answer

It may make more sense to create the desired visual style using CSS alone. This keeps presentation separate from content generation.

li.cat-item { 
  background: url(../image/arrows.png) no-repeat;

You may already know this, as you are using the parameters already, but you would of course need to remove the “&title_li=” from the parameters to keep the CSS hooks.

share|improve this answer
Yeah I thought about that, to be honest i just was lazy and appended the &raquo; via jquery :) – nikibrown Feb 1 '11 at 3:54

After much searching myselft, I found the answer to this here:

To summarise, the code to append a '>' to the end of each category is:


    $taxonomy     = 'category taxonomy';
    $orderby      = 'name';
    $show_count   = 1;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 1;      // 1 for yes, 0 for no
    $title        = '';
    $empty        = 0;

    $args = array(
      'taxonomy'     => $taxonomy,
      'orderby'      => $orderby,
      'show_count'   => $show_count,
      'pad_counts'   => $pad_counts,
      'hierarchical' => $hierarchical,
      'title_li'     => $title,
      'hide_empty'   => $empty

        $variable = wp_list_categories($args);
        $variable = str_replace('</a>', ' &gt;</a>', $variable);
        echo $variable; 

Hope this helps. The key is the $empty parameter.

share|improve this answer

i would say either the css or use jquery to append. Say its in your div#sidebar, you could do something like

$('#sidebar ul li a').append('&lt;span style="color:#ff0000;"&gt;htmlmarkuphere&lt;/ span&gt;'); 

and itd at least be displayed in line and inside the anchor. or do append to the li to get it after the a but in the li.

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.