最简单的解决方案:
echo get_the_category_list( \', \' );
按照您的方式:
更改您的$args
像这样:
$args = array(
\'template\' => \'%2$l\',
\'term_template\' => \'%2$s\',
);
然后,将此添加到
functions.php
文件(
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;
});