Home Articles How to make a tag cloud page

How to make a tag cloud page

2315
50
SHARE

Have you noticed that many blogs have a tag cloud in their sidebars? however, not many have a tag cloud page. Why a tag cloud page you may ask! Well… many reasons: de-cluttering your sidebar, adding interactivity to your blog, … Or maybe you have so many tags that they don’t fit in your regular tag cloud widget.

So that’s what this tutorial is about: creating a tag cloud page.

Before we start

Before we start, you need to be running WordPress version 2.3 or later, and of course have a bunch of posts with tags, otherwise you may end up with an empty tag cloud.

Creating the page template

First, we need to create a custom page template. A page template is nothing more than a PHP file with a special commented code at the beginning of the file.

Go ahead an create a new php file and name it “tagcloud.php” or whatever you want. Now put the following at the beginning of it:


<?php
/*
Template Name: Tag Cloud
*/
?>

With this we’re telling WordPress that our tagcloud.php file is a page template and it’s name is “Tag Cloud”.

The basic structure

Now let’s add the basic page structure, header, sidebar and footer. Of course, this depends on the theme you’re using. I’m just going to assume we’re using the Kubrick theme structure for this tutorial. I recommend you open the page.php file of your theme and try to replicate it. The resulting file might look something like this:





That would print an empty page because we haven’t inserted the template tag yet.

The template tag

Now we need to put in the tag cloud template tag: wp_tag_cloud(), which will print the tag cloud. You can find more information on the wp_tag_cloud() template tag in the codex.

Okay, let’s add the template tag:





 

Notice that we entered “number=0” parameter, this is because, by default, the wp_tag_cloud() template tag only prints the 45 most used tags, and we want to display them all instead.

Also, we’ve placed the template tag inside a div with a class of “tag_cloud” in case we need to style it later with some CSS.

We’re done with the PHP part, now save your file and upload it to your theme directory (wp-content/themes/your_theme_name).

Creating a new page in WordPress

All we need to do now is create the page in WordPress. To do this, you just have to follow these steps:

  1. Go to the Write » Page section of the admin panel.
  2. Type a descriptive title for the page in the Title field.
  3. Locate the Page Template panel, open it if it’s closed, and choose “Tag Cloud” from the drop-down menu.
  4. Hit the Publish button.

And we’re done. Feel free to post your thoughts and questions in the Comments section.

50 COMMENTS

  1. First of all… GREAT site! I just found it via Weblog Tools Collection (and I’m definitely going to try your Pistachio theme). I do have my tag archive done the way you explained it, yet, I’ve been cracking my head with something. I just to have a really cool tag archive using and add on for Ultimate Tag Warrior. When UTW became obsolete, the functions were lost.

    The add on displayed the tags in a list format, which you can also do with the wp_tag_cloud tag, but I can’t figure out a way to make the columns show as the add on did. Since I saw you modified an Alex King plug in, would it be too much to ask you to take a look at the add on code? I hope you can! (link)

    Again, thank you for the site, I found a couple tricks I’m going to try.

  2. @Fer: I have never used the Ultimate Tag Warrior plugin, but, I found this site which offers a version of the plugin that still allows you to use the plugin functions, but with the native WordPress tags. Maybe that’ll work for you.

    Oh… and thanks for the compliments 😉

  3. Well done – I was after this as a plug in and looked for ages. So I have found this instead, I had no idea that I had this many tags. Only down side is – I don’t know how effective this will be for the google bot or SEO purposes.

    But great guide and straight forward !!

  4. Hey, Normally I don’t bookmark many sites, and i mean it’s quite rare.. but i’ve been looking forever to find a site that explained how to do this without installing any other plugins and you did it. I appreciate that. Good site you’ve got here, and thank you.

  5. Hi,

    Thank you very much for this easy to use guide, I have already implemented it on some of my clients sites.

    Great work!

    Ronny

  6. very cool. Worked exactly. Any chance in adding some style tho? Mine looks ugly as is and for some reason extends beyond the posting dimensions. click on my name about to go to the site. Please help.

  7. hi. thanks for the great directions. I have it working on my site, but I can’t seem to style the type the way I want. My CSS is iffy at best and I wonder if you could illuminate this sentence for me:

    “Also, we’ve placed the template tag inside a div with a class of “tag_cloud” in case we need to style it later with some CSS.”

  8. Didn’t show all the code. Trying again

    <div >

    ‘.__(‘Pages’,’gpp_i18n’).’: ‘, ‘after’ => ”, ‘next_or_number’ => ‘number’)); ?>

    <?php edit_post_link(__(‘Edit this entry’,’gpp_i18n’), ”, ‘.’); ?>

  9. Shit, sorry. Why can’t I paste all the code? Any hints on where to put the template tag in? I’ve tried just a few places, and can’t get it to work right.
    Thanks again

  10. Hi, thanks for the tips. Just one question, I’m having more than 100 tags on my tags cloud page. I want every tags to be included, but paginated at 100 tags per page. Is there any solution for this? Thanks.

  11. Thanks for the tutorial!

    I’m trying to use the topic_count_text_callback=default_topic_count_text argument, but I’m not getting what I had hoped. I had hoped to see the count per tag in parentheses following the tag, but instead the callback function puts the count in the TITLE attribute.

    Is there an argument value for topic_count_text_callback that would allow me to present the tag count?

    Thanks!

    • Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something.
      I think that you could do with a few pics to drive the message home a bit, but other than
      that, this is fantastic blog. An excellent read. I’ll definitely
      be back.

    • Admiring the hard work you put into your blog and
      detailed information you offer. It’s nice to come across
      a blog every once in a while that isn’t the same unwanted rehashed material.
      Wonderful read! I’ve saved your site and I’m adding your RSS
      feeds to my Google account.

  12. Thank you for the great tip. You provided the basic thought and I added some more code and it worked great!
    I added more code because when put like that, the theme’s sidebar got all messed-up. I had to define it like the rest of the page templates in my theme and it’s awesome!
    Thank you!

  13. Hi,

    Thanks for the post, Its working fine, but if we are having more then 10000 tags then its not a good idea to show all the tags on a single page, so I just want to know that is it possible to create pagination for tag page so that we can show all of our tags.

    Thanks
    Waiting for reply.

Comments are closed.