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?
2 Answers
According to the Wordpress Codex on tag clouds, you need to specify a comma as the "separator" argument.
$args = "separator"=>",";
wp_tag_cloud($args);
-
-
@JoeBobby If I understand what you want to do, you can create your own wordpress widget– fdsaCommented Aug 19, 2012 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');