Using <?php wp_tag_cloud(''); ?> to display tags on my website, how do I separate each tag with a comma but also remove the comma from the last tag?


According to the Wordpress Codex on tag clouds, you need to specify a comma as the "separator" argument.

$args = "separator"=>",";
  • where would I enter that though? – Joe Bobby Aug 19 '12 at 2:57
  • @JoeBobby If I understand what you want to do, you can create your own wordpress widget – fdsa Aug 19 '12 at 22:29
 Filter the seperator arg for the tag cloud function. Put the following in your theme's functions.php

 * Filter arguments of tag cloud widget to enlarge our text and
 * add commas
function myfunc_filter_tag_cloud($args) {
    $args['smallest'] = 18;
    $args['largest'] = 32;
    $args['unit'] = 'px';
    $args['separator']= ', ';
    return $args;
add_filter ( 'widget_tag_cloud_args', 'myfunc_filter_tag_cloud');
  • it didnt work could you paste in a code block? – Joe Bobby Aug 19 '12 at 2:57

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.