A Tag System Based on Categories July 23, 2005
I have managed to put together a complete tag system built on top of Wordpress categories. Using both plugins of my own and plugins written by others, I was able to build a system that can show all tags, show popular tags, show tags for each post, show related tags for each post, build Technorati tags, and easily add tags to a post via the administration interface. The first step was to decide that I wanted to use tags. This happened for me after interviewing Jonas Luster, product manager for Technorati and all-around good guy. One of my questions to Jonas was “What are some of the new trends in blogging that will become big in the next year or two?” His answer in part was “most definitely tagging.” When he first said this, I didn’t really understand why, but after looking into it, I realized how important tags are to building social networks, promoting social classification, folksonomy, and distributed classification. That’s when I realized the real value of tags and decided to change my wordpress installation from a category based system (and indeed mindset) to a tag based system.
When I started working on this project, I didn’t realize that there were a multitude of plugins out there that allow one to add a tag system to wordpress. I’m glad I didn’t know this because I might not have spent the time building my own. All of the tag systems I’ve seen are seperate from Wordpress categories, which I don’t like very much. I wanted to use something based on the built-in category system because I had already posted a few entries and I didn’t want to have to go back and re-tag everything. Of course, some of the plugins out there have built-in tools to do this for you, but nontheless, I was determined to build a tag system on top of Wordpress categories. I was able to do so without modification to the core Wordpress files or the database. This was one of my personal requirements because I didn’t want to mess things up for myself if I were to upgrade.
I’ve broken things down into two main categories (no pun intended) The first being steps for administration and the second being steps for displaying tags on the blog. Okay, on to the good stuff.
Steps for Administration
Step 1. (optional but recommended)
The first step is to set your category base to /tag. You can do this under options->permalinks.
Step2.
Install the very wonderful cat2tag plugin. This plugin removes the category list on the right side of the admin panel when writing a post and replaces it with a tag system underneath your post box very much like the way Del.icio.us tags look).
Steps for displaying tags
Step 1.
I’ve created a plugin, (very much in its alpha stages, so USE AT YOUR OWN RISK) to display popular tags, related tags, and build technorati tags–all based on the built-in wordpress category system. It contains the following functions:
show_tags($limit)
This function displays tags for the current post, along with an rss feed for each tag and it builds a technorati tag as well. Feel free to steal the image I use to display Technorati tags for your own use.
related_tags($id, $rlimit=0, $before='’, $after='’)
This function displays a list of related tags for the current post. I use it like so:
< ?php related_tags($post->ID, 15, ‘’, ‘’); ?>
This function was tricky, and I ultimately use the sql provided by LaughingMeme in this post. This function is very very very alpha, but it seems to be holding together for the time being. We’ll see what happens as my tag list grows.
popular_tags()
Of course I use popular tags, which I’ve rolled into this plugin. I also made a small change to the code so that popular tags get displayed in alphabetical order. Directions on using the popular tags plugin can be found here.
Step 2.
I also use the weighted tags plugin by Matt Kingston, but I’ve modified it slightly to fix a bug, you can get my modified version here. I use this plugin to display tags on my archives page, which is in much need of a redesign by the way.
That about does it. That is how I’ve implemented a full-blown tagging system on squible. The plugin I’ve written is very very alpha, so please don’t ask me to support you, I’m still figuring it out myself, but you are more than welcome to use it. If anyone adds aything to this plugin or has ideas for adding something, please let me know–I’m all about making this system as useful as possible.

Loading...
81 Responses to “A Tag System Based on Categories”
Hi. I surfed in via BlogExplosion.
I love the design of your site. Great content, too. ‘m gonna sub :)
I’m using bunny’s tags, and it seems to be working pretty well. My problem is that I always forget to tag my posts before I submit them.
I ma have to check out your system. It looks interesting.
I love your comments plug. I’ll be giving it a shot soon.
[…] daily bookmarks that I’ve added to del.icio.us into WordPress" // posted by t.a.l. @ 11:53 PM Comments: Post a Comment <<Home […]
[…] The theme is called Squible (hey, go figure) and the purpose of theme (besides putting out something that’s different from the herd) is to promote the use of social networking within Wordpress. How? By including the tag system I built that sits on top of Wordpress categories into the theme. […]
Do you have any idea why /tag as category base isn’t working on my site.
I must confess, I did that bit AFTER installing the plugin. To make things even worse, mod_rewrite isn’t working on my site either but circumvented with the index.php trick.
But everything else is just working out wonderfully.
“/tag” makes use of mod_rewrite (I believe), that could be why…
Somewhere in the script there must be the word »category« given for writing the URI. As soon as I find the time I will read through all that PHP scribble and replace it with »tag«. That is, of course, only if there is none of those brilliant, friendly and generally well disposed people around who are able to write a plugin to that purpose.
I just discovered a rather interesting bug: The last entry in my weighted category list get the URL [root]/blog/tag/[category id].
All other categories get the URL [root]/index.php/category/[category id].
The funny thing about it is that /tag as category base does not seem to work on my site and therefore that option is left blank.
As nice as the /blog/tag thingy is - it only appears on the last category in the list and leads straight to error 404.
Any idea of what might be happening there?
Andreas, this is in the popular_tags() function in the wp_cats_as_tags plugin, correct?
It is, but it seems to work only on the last on in the list.
I can tell by the link that it shows on your blog that you’re using the popular_tags plugin, not the wp_cats_as_tags plugin. Regardless, it is a bug and I fixed it in the popular_tags plugin and if you re-download it you should be all set.
You can download it here.
You’re my hero (no kidding). BUT it’s still not working. I uninstalled and re-installed »Cat 2 Tag«, »Popular Tags« (MK II), and »Weighted Categories« with no effect at all. The faulty link at the end of the category list persists. Even with all those plugins uninstalled that link stays firmly rooted in some reality of its own (apart, of course, from the database failure when »Weighted Categories« was gone).
Now I kicked out »Weighted Categories« and left the job to »Cat 3 Tag« and »Popular Tags«. The alphabetical order of the category list was set right (that’s a nice side affect). Still, the last entry points to 404 even though the »/bolg/tag« thingy is gone. Interestinly, the URL for the last entry takes the category name with a capital (»Wirtschaft«) instead of the category form without a capital. Something seems to be utterly messed up.
Since Jonas Luster is one of the programmers for WordPress, wouldn’t it be simply a future update for WordPress to changes Categories into Tags?
As of July, Jonas is no longer associated with WP.
Thanks to Theron the problem is solved by some hardcoding. As long as there are such helpful people around I am quite happy regarding every problem as just a new opportunity to meet friendly people.
Thanks. I will keep an eye on this. I am not a php expert, so I am afraid to tweak at the moment. The methods choose by Theron might be the best for tags in WordPress.
Theron, I don’t know why the tags in the mid panel under my posts can’t work at all. For example, my post is categorized as Cooking and Wine, so in the tag area, it shows Cooking and Wine. When I click to them, it said No such file in directory and server. Why? Thanks.
oh, i’m so sorry. what i meant by mid panel is the new squible skin. i’m terribly sorry for the dumb quest.
Can you send me a URL?
Theron, just click my name and that’s the link. Click to cultures or uncategorized in midpanel and it’ll redirect to the “custom 404″ page. Thnaks
It looks like you don’t have modrewrite turned on (from the permalinks page). Go to options->permalinks and set your permalinks structure.
Theron. I donnu why, but it’s probably not the problem with Squible; the server just don’t support permalinks no matter what theme i put in.
By anyway, this is the other case. May I know what I should do in order to let the “Tags” work?
In a situation where modrewrite isn’t available to you, you should download the ultimate tag warrior plugin and use that instead. Squible supports it.
but the thing is that it does not work on my XAMPP localdrive either. when i click to the tags, it said no such file on directory. or should i change category base (in permalinks) to something? And also, which is the correct pattern for my permalinks? /%year%/%monthnum%/y%/%postname%/
Yes, you have to change the category base in permalinks options in your admin’s control panel to “tag” (Quotation removed!) Try, and let me know, ok?
Pictures and Tags.
Now, this[1] I’ve got some issues with a plugin[2] from Squible. Aside from some formatting issues, which are certainly tied to my utter lack of php-fu, it seems to work. The only thing that seems strange is that it’s part of a larger co…
Hi Theron,
You could be the answer to my quest: I want do display three tag clouds at my sites: one for authors, one for source and one for keywords/tags. For tags I’ll use UTW, but it allows me only to display one tag cloud. My plan is to make categories out of the author names and the source names and to display them as separate clouds. But you have so many plugins as options, I fooled around with both weighted categories and popular tags but I can’t get it to work.
Can you tell me which plugin to use and how?
I’ll greatly appreciate it…
Gerard
[…] A Tag System Based on Categories […]
I installed the cat2tag plugin, which seems to work fine. But when I tried installing (and activating) your plugin, I get the following error:
Fatal error: Cannot redeclare popular_tags() (previously declared in /home/.gazoo/chuggins/fp.philosophyblog.net/wp-content/plugins/wp_cats_as_tags.php:11) in /home/.gazoo/chuggins/fp.philosophyblog.net/wp-content/themes/squible/builtin/wp_cats_as_tags.php on line 11
Any thoughts? Thanks!
Yes, it looks like you’re already using my popular_tags plugin, all you have to do is disable that and you should be good to go.
I deactivated the plugin, but then there was a problem whereby I got a 404 error when I clicked on the tag link (e.g., it couldn’t find http://fp.philospophyblog.net/philosophy).
I actually fixed the problem by changing my permalink settings so that the category was included in the post link (my virtual site structure is now: /tegory%/%post_id%).
I don’t know what that did, precisely, but everything seems to be working a-okay. Thanks so much!
i’m sorry but this is off-topic, i noticed that in IE, the date shown on all the comments is just “July 23rd, 2005″…
That’s odd. Thanks for pointing it out, I’ll look into it.
Hi there,
Great plug-in. I was wondering what you use to search through tags. After all, the only disadvantage to tagging over categories is that you will quickly have many more tags than you had categories. So listing them is not really a viable option. What do you do to search tags?
[…] the home for the Squible Wordpress theme. The purpose of theme (besides putting out something that’s different from the herd) is to promote the use of social networking within Wordpress. How? By including the tag system I built that sits on top of Wordpress categories into the theme. Other neat features include an advanced layout, support for multiple plugins, the ability for registered users to add tags, livesearc Tags […]
This is so great. Grabbing it, or should I just use your theme? Yeah, I’ll use your theme instead with a built-in tag capability :)
[…] wp_cats_as_tags(innebygget) […]
[…] categorías como tags […]
[…] wp_cats_as_tags what: modifies wordpress’ category system to be more like del.icio.us tags. rate: 2/10. maybe i’d like it if i had more than 10 categories? but then i’d probably use tags exclusively, and not rely on the wordpress category system. […]
Greetings. A good friend is using your template, and I was interested in your system for creating and displaying tags. I found this post, reset my Category Base to /tag, and downloaded and installed the cat2tag plugin. Everything worked fine.
Then I downloaded and installed your wp_cats_as_tags.phps plugin. I saved it as a .php file, uploaded it to my plugin directory, and activated it. Nothing happened.
I am not .php savvy by any means, and am wondering what I am missing, or do not understand, in order to invoke your plugin, to see if it will work on my site. If you have any helpful advice, I would be very grateful.
Thank you kindly, and best regards,
Randy.
Theron,
Does this procedure change if you’re using Wordpress 2?
[…] The Squible theme can be found at http://www.squible.com/squible/. The purpose of theme (besides putting out something that’s different from the herd) is to promote the use of social networking within Wordpress. How? By including the tag system I built that sits on top of Wordpress categories into the theme. Other neat features include an advanced layout, support for multiple plugins, the ability for registered users to add tags, livesearch, ajax commenting and an archives page with support for extended live archives. […]
can’t download cat2tag plugin. get the following message: “This domain is parked, pending renewal, or has expired. Please contact the domain provider with questions.”
is there an alternate download link for this plugin?
[…] http://www.squible.com/2005/07/23/a-tag-system-based-on-wordpress-categories/ Tags […]
Beautiful job guys, on the tag system and the squible theme!
Is there anything we need to know for wordpress 2.0?
Michael
[…] And here’s an interesting wordpress plugin/process: a tag system based on categories. Cool, although with my crippled mod rewrite installation i wonder how well it will work…. Ah yes, in the comments there is the assertion mod_rewrite is required. Pity. (Are there more recent posts at squible about tagging?) […]
Very cool template. Not everyone has to totally agree, but I certainly do. I will add your site to my favorites.I will make sure to come back.
We all can have an opinion and be safe in expressing it. Great site by the way.
test
just testing the AJAX commenting system
[…] tag system, include an advanced layout, support for multiple plugins, the ability for registered users to add tags, livesearch, ajax commenting and an archives page with support for extended live archives. […]
[…] 具体使用说明在这里http://www.squible.com/2005/07/23/a-tag-system-based-on-wordpress-categories/ […]
[…] wp_cats_as_tags(builtin) […]
[…] 干掉category换成tags http://www.squible.com/2005/07/23/a-tag-system-based-on-wordpress-categories/ […]
[…] wp_cats_as_tags(builtin) […]
[…] wp_cats_as_tags(builtin) […]
I am trying to download cat2tag. I downloaded and up loaded it to my plugins directory. However, it won’t show up on the Plugins section.
Please Help. Also, your forum doesn’t seem to be getting much use.
Reviews From Innate Penis Enlargement Products
Desire several men with your position, you’re unhappy in on such a size from your penis. As long as everyone weren’t, you wouldn’t arrive. Such a vast majority from women such as a sufficient penis as well as one applaud your effort with making an attempt to inflate yourself. What’s this smartest enlargement solution? Read over superior penis enlargement solution, adding together to 3 inches ist assured.
porn movie download…
porn movie download…
Realy? That’s 70727 crazy!!
dude, ur getting spam comments like crazy, read up!
Nice job in the tagg system!!
Top 3 penis enlargement pills.
And some else…….
the most interest…
http://hometown.aol.com/DrOlva3872/ DrOlva3873
I want go home.
Hello, nice site look this:
And my grandpa is a train finatic.
End ^) See you
Pretty Interesting.
I found your blog via Google while searching for and your post regarding A Tag System Based on Categories looks very interesting for me
注册公司
服装厂
美术培训
thanks a lot
Wow.
IGpsq9 hi great site thx http://peace.com
Great tip
fpqwK6 nice site thx http://peace.com
[…] This is the home for the Squible Wordpress theme. The purpose of theme (besides putting out something that’s different from the herd) is to promote the use of social networking within Wordpress. How? By including the tag system I built that sits on top of Wordpress categories into the theme. Other neat features include an advanced layout, support for multiple plugins, the ability for registered users to add tags, livesearch, ajax commenting and an archives page with support for extended live archives. For the latest and greatest information, see the official Squible discussion board at Thought Mechanics. For announcements, subscribe to the google group. […]
Thanks for a very thought provoking post.
nice