valibuk.net

A place for opinions and notes of a valibuk.

Updating from Categories to Tags in WordPress

Tagged with: — ondrej at 12:47 am on Wednesday, November 28, 2007

I updated my WordPress installation to the version 2.3.x and found a new feature: tags.
I converted all my categories to tags (except the Uncategorized category) and… what I saw a small disaster :) All categories disappeared (an expected result), but the categories list in my sidebar contained only one, not very useful, item Uncategorized. Additionally a blog entry contained only Filed under: Uncategorized, again, not very helpful.

And then I realised - I have my own theme… arrrrgh…. and there is no tags to categories converter ;>
Well, here are steps how to update your own theme to support basic tags features:

1. Blog Entry
We are going to change from Filed under: Uncategorized to Tagged with: English • Photos • Travelling.

Open the wp-content/themes/YOUR_THEME/index.php file and change:

  1. <?php _e("Filed under:"); ?> <?php the_category(‘,’) ?>

to

  1. <?php the_tags(‘Tagged with: ‘,‘ &bull; ‘,); ?>

2. Sidebar
We are going to remove the obsolete categories list and replace it with a new shiny tag cloud:

Open the wp-content/themes/YOUR_THEME/sidebar.php file and change:

  1. <li id="categories"><h4><?php _e(‘Categories:’); ?></h4>
  2.  <ul>
  3.  <?php wp_list_cats(); ?>
  4.  </ul>
  5.  </li>

to

  1. <li id="categories"><h4><?php _e(‘Tags:’); ?></h4>
  2. <ul>
  3. <?php wp_tag_cloud(); ?>
  4. </ul>
  5. </li>

Actually, I decided for smaller font sizes:

  1. <?php wp_tag_cloud(‘largest=18′); ?>

Please, do not forget to click on [Show Plain Code] before copying source code.

For more details about the new commands see the version 2.3 announcement.
For more details about categories and tags see this apt blog entry: Tags Are Not Categories - Got It?.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • DZone
  • Digg
  • Reddit
  • Technorati
  • Furl
  • NewsVine
  • Slashdot
  • Ma.gnolia
  • StumbleUpon

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment Preview


commercial break :)

Make an account on slicehost.com -- a really good hosting where you have your own virtual machine. I installed Gentoo there = I like it very much ;)