WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to output an ordered list of the top five tags for my site into the sidebar.

At the moment, I'm using wp_tag_cloud like this to get it to output a nice <ul>:


However, I'd like it to output as an <ol> instead of a <ul>. Is it possible to do this without hacking the core? Presumably via functions.php or the like?

Also, in the output from wp_tag_cloud, the font size is being set by inline styles. Seeing as I don't need the tag cloud to actually function as a tag cloud, is there any way to simply remove all inline styling from it?

Finally, if there's an easier or less convoluted way of getting an ordered list of tags, please let me know.


share|improve this question
up vote 5 down vote accepted

one possibility: using the 'format=array' and 'echo=0' parameters; and building a foreach loop to output each tag:

  $wptc = wp_tag_cloud('smallest=12&largest=12&orderby=count&order=DESC&format=array&unit=px&number=5&echo=0'); 
  foreach( $wptc as $wpt ) echo "<li>" . $wpt . "</li>\n"; 
share|improve this answer
That does the trick, thanks! Do you know if there's any way to remove the inline styles, also? – snthr Jun 21 '11 at 10:01
you could use a filter function - added to functions.php of your theme; example: add_filter ( 'wp_tag_cloud', 'no_inline_style_tag_cloud' ); function no_inline_style_tag_cloud( $list ) { $list = preg_replace('/style=("|\')(.*?)("|\')/','',$list); return $list; } – Michael Jun 21 '11 at 12:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.