I was pretty annoyed with the default tag cloud widget. It does a lot of things wrong, like inconsistent HTML markup and hardcoded font sizes. So I wanted to write my own. Digging through the code I found out that the wordpress wp_tag_cloud()
function is pretty powerful. In fact, it could do almost everyhing I want. So I abandoned my plan to rewrite everything from scratch and added a nice admin interface to my tag cloud widget.
This plugin makes the options for wp_tag_cloud() available to a tag cloud widget and a shortcode. This means that you can easily choose things like font sizes, HTML markup and ordering. See the wp_tag_cloud page for what the settings can do.
Additionally, it is possible to sort tags by count and alphabetically at the same time. It is also possible to add a counter to the tags, so that your visitors can see how many posts are associated with each tag. The plugin also adds a sensible CSS class to every tag.
Here's a demo of the new shortcode:
Tag cloud
feeds RSS feeds template Typo3 typoscript plugin WordPress CSS HTML YAML theme Webdesign realurl SEO SQL WordPress plugin JavaScript onclick onfocus apache duplicate content lighttpd redirect server git test theme theme preview theme switch theme switcher balloons christmas showstorm snow valentine better tag cloud configurable tag cloud flexible tag cloud improved tag cloud tag cloud fireworks move comments WordPress comments easy mail form simple zero conf mail delete comments delete pending comments custom avatars clicktracking jQuery marketing usability navigation WPMU ajax WordPress theme autotag category custom taxonomy PHP tag pagination options page settings api login custom post type development WordPress page WordPress post file upload paste pastebin recent posts Widget related content related posts query cool uri rewrite api 404 search search form order posts WordPress query meta data WordPress network bash cookies password recursive download wget rant yaml mootools howto border-radius safari virtual hosts audio Linux mp3 mailman title opera advertising geotargeting openx targeting Debian kernel wlan comments desktop openbox xorg mac powerbook accents keymap firefox ext4 gphoto2 photography powershot svn Custom Loop video shortcode WordPress loop security rewrite wp_nav_menu cups printer printing wp_enqueue_style simpleXML XML DOM HTML parser innerHTML fuse sshfs minify wp_register_style spam keywords separator import PageRank django virtualenv init gunicorn debianUsage
The easiest way to use this plugin is to drag the widget into one of your sidebars.
There is as well the shortcode [nktagcloud]. Examples:
- [nktagcloud] This displays the tag cloud as configured on the options page.
- [nktagcloud single=yes] This does the same but shows only the tags of the current post.
- [nktagcloud post_id=1234] Displays the tags of the post identified by post_id.
- [nktagcloud separator="" categories=no] Remove separator and categories.
Using the tag cloud in your theme
You can call the function nktagcloud_shortcode()
from your theme to get the same output as from the shortcode. Example:
<?php
if ( function_exists( 'nktagcloud_shortcode' ) ) {
echo nktagcloud_shortcode( null );
}
There's also the nk_wp_tag_cloud()
function. You can use it to generate a tag cloud with a different configuration than the plugin's one. It accepts the same parameters as wp_tag_cloud(). Example:
<?php
if ( function_exists( 'nk_wp_tag_cloud' ) ) {
echo nk_wp_tag_cloud( 'single=yes&separator= - &categories=no' );
}?>
Additonal parameters (all strings):
- single: Only tags of the current post ('Yes', 'No')
- categories: Inlude categories in the cloud ('Yes', 'No')
- replace: Convert blanks to non-breaking spaces ('Yes', 'No')
- post_id: Display only tags of the specified post (post ID)
- mincount: Show only tags that have been used at least so many times
- separator: Tag separator
- inject_count: Add a counter to the tag ('Yes', 'No')
- inject_count_outside: Add the counter outside of the tag hyperlink ('Yes', 'No')
- nofollow: Add the noffow attribute to the tags in the cloud ('Yes', 'No')
Downloads are at the plugin's WordPress.org page.
Most plugin demos are disabled at the moment. I'll restore them as soon as possible.
if ( function_exists( 'nk_wp_tag_cloud' ) ) { echo nk_wp_tag_cloud( "post_id=1234" ); }
This works with the new 0.10.0 release, not sure about older versions..widget-nktagcloud ul { foo }
or something similar should work I imaginedisplay: block;
maybe?echo apply_filters( 'the_title', $config['title'] );
.widget_nktagcloud a { text-decoration: none !important; }
I hope this works.href="http://example.com/tag/mytag"
and I would need to change this tohref="http://example.com/wp-content/tagdir/mytag.gif"
Is that possible and where would I make that change?single=yes
only shows tags of the current post, so no tags on pages, the blog page etc.nktagcloud_the_cloud()
for that.echo nktagcloud_the_cloud();
but I recieved Warning: Missing argument 1 for nktagcloud_the_cloud(), called in ... can I fix that? Thank you. Rnk_wp_tag_cloud()
for the second cloud.if ( function_exists( 'nk_wp_tag_cloud' ) ) { echo nk_wp_tag_cloud( 'single=yes&separator= - &categories=no' ); }
Additonal parameters (all strings): * single: Only tags of the current post ('Yes', 'No') * categories: Inlude categories in the cloud ('Yes', 'No') * replace: Convert blanks to non-breaking spaces ('Yes', 'No') * post_id: Display only tags of the specified post (post ID) * mincount: Show only tags that have been used at least so many times * separator: Tag separator * inject_count: Add a counter to the tag ('Yes', 'No') * inject_count_outside: Add the counter outside of the tag hyperlink ('Yes', 'No')widget_nktagcloud
. Or just check your site's source ;-)