1

How can a tag cloud generate a list of tags WITHOUT the links? This works fine for me, but I just don't want the links:

wp_tag_cloud('smallest=10&largest=10&number=0&format=list'); 

Didn't see anything explicitly in here about this: http://codex.wordpress.org/Function_Reference/wp_tag_cloud

There are similar questions on here, but they have to do with tags for a particular post. I don't want the current page/post tags. I want all tags used on the site in a tag cloud. Display tags in list without link

1

We can modify the output with the filters wp_tag_cloud or wp_generate_tag_cloud.

But we could also use:

echo strip_tags(
    wp_tag_cloud( 'echo=0&smallest=10&largest=10&number=0&format=list' ),
    '<ul><li>'
); 

where we strip all the HTML tags from the output, except the ul and li tags.

Notice that we added the echo=0 parameter as mentioned in the Codex as a way to return the output. We could also have used echo= because it has to full fill the condition:

if ( 'array' == $args['format'] || empty($args['echo']) )

to return the output. So empty( null ) and empty( '' ) is true but it's strange that empty( 0 ) is also true, but that's just how the empty() function works ;-)

The wp_tag_cloud() function has the link parameter, but it only has the possible values as view or edit. It would be nice to have the none option, to disable links and show only the text.

  • Great answer. I was thinking about stripping the "href" attribute with Javascript, but I like your server-side solution better. (Also had the same thought about the NONE option.) – Doug Oct 9 '14 at 3:20

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.