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>
:
wp_tag_cloud('smallest=12&largest=12&orderby=count&order=DESC&format=list&unit=px&number=5');
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.
Thanks.
1 Answer
one possibility: using the ‘format=array’ and ‘echo=0’ parameters; and building a foreach loop to output each tag:
<ol>
<?php
$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";
?>
</ol>