I want to display the taxonomies within the loop but with customized template.

Here is my code:

if ( have_posts() ) {
    while ( have_posts() ) {
        $args = array(
            'template' => '%s %l',
            'term_template' => '%2$s',


The post is in the two categories: "Neues" and "Zweite". This code shows the post with the taxonomies like this:

"Kategorien Neues und Zweite"

how can I change the output like this:

"Neues, Zweite"

without the string "Kategorien" and another seperator "und"?

I tried the $arg = 'sep' => ', ' but this changes nothing.

Thx for help!

1 Answer 1


The simplest solution:

echo get_the_category_list( ', ' );

Following your way:

Change your $args like so:

$args = array(
        'template' => '%2$l',
        'term_template' => '%2$s',

And then, add this to your functions.php file (this will affect all %l markers!);

add_filter( 'wp_sprintf_l', function($templates) {  
    // $templates['between_last_two'] = sprintf( __('%s, and %s'), '', '' );
    // $templates['between_only_two'] = sprintf( __('%s and %s'), '', '' );

    $templates['between_last_two'] = sprintf( '%s, %s', '', '' );
    $templates['between_only_two'] = sprintf( '%s, %s', '', '' );

    return $templates;

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.