A day in the life II random header image

Tags in Wordpress

December 3rd, 2007 by Malcolm

Wordpress 2.3 added tags, like the ones we use in LiveJournal, so how do we enable them?

First, I followed this entry’s advice in the WordPress Codex and added my tag cloud to my theme’s sidebar file (sidebar.php - which you can do from within the admin interface).

Basically I put this code:

<h2>This Blog's Tag Cloud</h2>
<ul><?php wp_tag_cloud('smallest=8&largest=22&number=50&orderby=count'); ?></ul>

in the sidebar.php file where I wanted it.

Second, I noted that my theme lists Categories as tags in the sidebar file, so I went out to fix that.

This other article in the Codex provided the answer. I put this code:

<?php the_tags('Tagged as:', ', ', ''); ?>

in my Main Index Template (index.php) and Page Template (page.php) where I wanted it.

This didn’t actually work, but I tracked it down to the fact that my “The Loop” in the theme I’m using is written for an older version of WordPress, so I also had to update my The Loop in both index.php and page.php for the Version 1.5+ Wordpress functions. Here’s a good article from the Codex on The Loop. After I made these fixes to my The Loop, everything worked fine!

Almost forgot: The last thing I did was delete all my old categories (there’s a built-in tool to convert them to tags, if you like), and renamed the “Uncategorized” category to “Everything”. Now I’m committed to just using tags to categorize my posts, and as long as I stick with this theme, it should display tags properly as both a tag cloud in the sidebar as well as tags listed for each individual post.

P.S. Oops, forgot to modify The Loop and insert tags markup in the Single Post (single.php).

Tags:   · · No Comments

You must log in to post a comment.

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form above!