How can I use separator with wp_list_categories using inline list? In documentation they say (string) Separator between links. Default '<br />'. Well I guess that means I could use HTML right? I was thinking about using &middot; to connect items like I have in image but nothing happens.

enter image description here

    'title_li' => '',
    'child_of' => get_cat_ID('mycatname'),
    'hide_empty' => true,
    'show_option_none' => false,
    'separator' => '&middot;'

I tried putting something else as separator, but nothing happens so I wonder if it even works or am I missing something?

    $arr = wp_list_categories(array(
        'title_li' => '',
        'child_of' => get_cat_ID('Biljke'),
        'hide_empty' => true,
        'show_option_none' => false,
        'separator' => '-----',
  • 1
    Are you sure you are using the last version of WordPress? separator parameter is introduced just some subversions ago. – Max Yudin Apr 24 '16 at 11:37

It looks like the default of the style input parameter is list.

Try something like:

'separator' => '&middot;',
'style'     => 'separator',  // something else than 'list'

to override the list default.

We can see why this happens by peeking into the Walker_Category::start_el() method. There we have the following:

if ( 'list' == $args['style'] ) {
    // ...cut ...
 } elseif ( isset( $args['separator'] ) ) {
     $output .= "\t$link" . $args['separator'] . "\n";
 } else {
     $output .= "\t$link<br />\n";
  • Downvote, sorry, but this also adds the separator after the last term. I guess you could use implode to fix this but not sure how. – Dev Sep 27 '20 at 4:33
  • @Dev that sounds like a core bug. You could grab and edit the returned output with "echo" argument as false. Check e.g. this from the Related list, here to right. – birgire Sep 27 '20 at 16:41
  • Seems to be a core bug to me. Maybe someone should file a core bug report. – Dev Sep 28 '20 at 2:58
  • feel free to report that bug :-) – birgire Sep 28 '20 at 14:31
  • Thank you, i might if i can work out a patch or fix. Not sure what its called. – Dev Sep 28 '20 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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