I wanted to output all my categories in the sidebar of my wordpress theme. Now I use the function wp_list_categories(); which works fine. However it always displays the categories in a list and I don't want that.

What I want is to display the categories as links so that they are inline elements. I could stay with the list and just style them as inline elements by applying display: inline-block; to the list items. I guess it is semantically correct, too.

So is there a way of getting rid of the list in WordPress or should I stay with my approach? And is it semantically correct?

Thanks for all your answers.

1 Answer 1


Did you had a look at the Display Categories Assigned to a Post example in wp_list_categories in the Codex. This should give you a very good idea on how to modify your own code. This is just my simplistic way to achieve what you want. Feel free to modify as needed

$taxonomy = 'category';
$separator = ', ';

if ( !is_wp_error( $post_terms ) ) {

    $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy );
    $terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );

    // display post categories
    echo  $terms;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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