
Aziz of metaBLOG suggests that the new tags in Wordpress 2.3 can be used to create a “folksonomy” on Wordpress blogs. For those not in the know (including me until a couple days ago), a folksonomy is is the practice and method of collaboratively creating and managing tags to annotate and categorize content
according to Wikipedia. Basically it’s letting normal people (versus say artificial intelligence or an administrator) help describe things. For example, adding a tag on flickr or using del.icio.us.
So since Wordpress doesn’t currently have anything like a public “Add a Tag” and I haven’t coded a Wordpress plugin recently (although I did upgrade WP_MonsterID if anyone is using it), I thought I would code up a quick plugin to see how it works. So here is WP_Folksonomy. It’s fairly basic at the moment but I’d like to get it out there to see if it’s useful and if anyone is interested in it.
Since it uses Wordpress’s tagging features WP it’s only going to be compatible with Wordpress 2.3 and up.
Features
- Allow readers (or registered users) to add tags to posts
- Choose between immediately displaying tags and waiting for admin approval first
- Delete user submitted tags
- Delete or approve all tags by user/IP address
- RSS feed for monitoring added tags
- Javascript autocompletion for increased tag standardization
- Limit tags per time limit to discourage bots
Current Version:
Installation instructions:
Unzip wp_folksonomy.zip. Upload wp_folksonomy.php to wp-content/plugins/ and activate in the Plugin Control Panel. Now the slightly difficult part. Unfortunately there is no automatic hook near the tags in Wordpress so you’ll have to make a minor change to one of your theme files. We’re aiming create a tiny form to allow your users to add tags. Many themes will be using the wordpress <?php the_tags('some','options');?> to list the tags. Try to find this function or a similar tag listing function. It’s often either in wp-content/themes/CurrenTheme/index.php or wp-content/themes/CurrenTheme/single.php. Once you find it add the following code <?php if(function_exists('wp_folksonomy_add_form')) wp_folksonomy_add_form();?> immediately after it. For example in the default Wordpress theme, it looks like:
<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
<?php if(function_exists('wp_folksonomy_add_form')) wp_folksonomy_add_form();?>
Sorry it’s not more automatic but if you’re having any trouble figuring out where to put it feel free to ask in the comments (make sure to tell me which theme you’re using). You can view and delete tags from the Folksonomy control panel in Settings or a little widget on the dashboard an RSS feed.
Change Log:
- v0.8 9-22-2008:
- Put in a time limit for max tags per time to discourage bots
- v0.71 7-5-2008:
- Fixed deleting problem with term_id vs term_taxonomy_id
- v0.62 5-28-2008:
- Added caching compatibility
- v0.61 5-28-2008:
- Fixed invalid HTML
- v0.6 5-27-2008:
- Fixed missing
$wpdb->prefix causing missing table - Fixed installation directions (extra “function ”)
- Added javascript tag completion
- Fixed paging on tag display
- Removed dashboard widget
- Added an RSS feed for monitoring added tags
- Fixed missing
- v0.5 12-21-2007:
- Fixed undeleteable tags when tag had been created, deleted, created
- Fixed added tag not displaying on submitter’s page until after reload in themes with a late call to
wp_head()
- v0.4 12-19-2007:
- Approve all tags by user/IP
- Delete all tags by user/IP
- Tags added within post page (no longer needs $_GET variables)
- v0.3 12-17-2007:
- Limit tags to 25 characters
- Only allows users who can edit posts to approve/delete tags
- Fixed option update bug
- When Registered Users options set, only displays tag add form for registered users
- v0.21 12-15-2007:
- Fixed overlap between tag add and comment add $_POST variables
- v0.2 12-15-2007:
- Added Control Panel
- Added Subscribers Only and Authorize Tags options
- Tracks submitted tags
- Added Delete and Accept Tag actions
- v0.1 12-14-2007:
- A rough public tag adder
ScottS-M | 16-Dec-07 at 3:57 am | Permalink
I’m going to try to add the tag “collaborative” to see if I’m full of crap…
It worked so the plugin appears to be working OK. Hmm except somehow commenting has gotten messed up. Version 0.21 will be out in a few minutes.
ScottS-M | 16-Dec-07 at 4:17 am | Permalink
Was a tiny overlap with $_POST variables between comment and tag adding. Everything should be ok now.
ScottS-M | 13-May-08 at 4:51 pm | Permalink
Hey who added “potential mess”? :)
George | 21-May-08 at 4:47 am | Permalink
I’m trying this out on my photoblog - the problem I’ve found is that I can’t find anywhere to moderate the tags - they can be submitted, but from then on, I can’t find them in the admin panel.. Any ideas?
ScottS-M | 21-May-08 at 8:22 am | Permalink
There should be a little widget in the dashboard and a Folksonomy control page in the Settings. Are those missing or just understandably easy to overlook (I just realized I don’t have anything above about that)? I just started working on an RSS feed so people can keep track a little easier since I always manage to ignore the dashboard. There should be an update in a few days.
ScottS-M | 27-May-08 at 10:36 pm | Permalink
@George
Hmm I think I found an error in the plugin that would have mesed up the tag display and storage in some installs (missing
global). That might have been the problem. It should be fixed in the new version 0.6.Steven Smethurst | 28-May-08 at 10:07 pm | Permalink
Hello
Suggestions:
- Only allowed to add n tags, each user is only allowed to add 3 or 4 or n tags to a post. Add and remove would be nice.
- Users can only add predefined tags a post.
- Add tag weight. The more the users add this tag to a specific post the larger it gets.
ScottS-M | 28-May-08 at 11:06 pm | Permalink
@Steven
Good suggestions. Tag weight definitely could be fun. It could combine well with some predefined tags for a sort of multiple index rating system. I’ll think about that.
Aziz Poonawalla | 18-Sep-08 at 9:09 am | Permalink
Scott,
I had to remove WP_Folksonomy from my install at Talk Islam because someone had managed to add over 1,000 menaingless tags, of the form tNt where N is a number from 1 to 999, to two (and only two) of my posts. I dont understand the motivation exactly since the tags just link to themselves, not externally, and the tags here are kind of random-looking rather than obscene or anything. Still, it was so many tags that I couldnt delete them all manually (incidentally, deleting all tags by IP address didnt seem towork. I note you have a newer version that may have addressed that problem). I ended uphavong to go into my database using myphpadmin and delete them all there.
whoevere added the tags is either very patient or is using an automated method. Is there some layer of additional security you could addd? maybe restrict users who are not registered users to wait 15 seconds before adding more tags to a post?
Also, if you can allow regexps for tag filtering and deletion that woudl be helpful. Allowing deletion of all tags by a range of IP addresses, not just single, would also be great. I am anxious to gt WP_Folksonomy back in action on Talk Islam since its got a pretty wide readership now and might be the largest instance of the plugin out there.
Aziz Poonawalla | 20-Sep-08 at 8:50 am | Permalink
oh, let me second Steven above for the limit of N tags by IP address (N set by the admin). I’d probably be generous and set it to 10 but the default could be lower (5 or so).
ScottS-M | 22-Sep-08 at 12:11 am | Permalink
You can now set the number of tags allowed per time limit in version 0.8. Hopefully that’ll discourage those stupid bots.
Miklas Njor | 18-Feb-09 at 1:04 pm | Permalink
Hi Scott.
Nice plugin that works straight out of the box.
I have a question though. The way it works now is that all the words punched into the box become one tag. Is there a way of separating them with commas og dashed, so the user doesn’t have to enter one tag and then press enter.
Kind Regards, Miklas.
ScottS-M | 20-Feb-09 at 11:03 am | Permalink
@Mikla Njor
That probably would be good. I wanted to make sure no one entered hundreds of spam tags all at once. But I guess we could seperate by commas and limit it to five or something.
Lloyd Sommerer | 25-Mar-09 at 10:42 pm | Permalink
This is super. I’ve been messing around with the plugin for the last day, and have a somewhat minimalistic installation on my site now. I’m going to point it out to visitors tomorrow and see what happens.
Thanks for putting this together.
Lloyd Sommerer | 27-Mar-09 at 7:25 am | Permalink
Success. We ended up with 601 user contributed tags in roughly 24 hours of tagging. I haven’t looked through all of the data yet, but it doesn’t look like anything malicious was added.
ScottS-M | 31-Mar-09 at 2:30 pm | Permalink
Wow that’s a lot of tags. A good test of the plugin. Glad to hear it worked for you.
Stefan Hauptmann | 29-Apr-09 at 12:18 pm | Permalink
I am using the new P2-theme for Microblogging. Would be a good feature for this theme as it only allows to add tags when writing the post.
However, I cannot find any code that begins with “the_tags”. Seems to be an Ajax-thing in P2.
Do you have an idea where to include this code-snippet, anyway?
Regards
Stefan
Stefan Hauptmann | 29-Apr-09 at 12:31 pm | Permalink
Hoh, I managed it to add the code to the single.php. The add-function shows up but when adding a tag a message is shown:
“Sorry adding tags not allowed on this post.”
Stefan Hauptmann | 29-Apr-09 at 12:34 pm | Permalink
SORRY - it works great :-)
ScottS-M | 29-Apr-09 at 2:07 pm | Permalink
Glad you got it working. Let me know if you have any trouble.
MikeonTV | 19-May-09 at 10:16 pm | Permalink
Thank gawd I found this plugin! Is there a way to allow a user to add more than one tag without having to send it over and over again. Perhaps by separating by commas?
ScottS-M | 20-May-09 at 4:12 pm | Permalink
I initially left out multiple tags to avoid spam but it doesn’t seem like it’d hurt to let people do up to say five tags. I’ll add that as an option to the next version.
MikeonTV | 26-May-09 at 10:58 pm | Permalink
Great. I look forward to it! AJAX too!!!
tiki god | 02-Jun-09 at 3:29 pm | Permalink
I’ve added a small bit of code around it so that only admins can see the plugin, and it’s perfect this way, no spam and I know what group of site members have access!
You can put my vote down for multiple tags too ;)
And ajax would be divine!
tiki god | 17-Jun-09 at 9:30 am | Permalink
I had a thought. Would it be possible to have an option to only permit already existing tags? Might help with tag spam, and would certainly help me with my inability to spell properly
Jon | 01-Jul-09 at 9:02 pm | Permalink
The message after tag submission seems to be wrong. I have Folksonomy set to hold tags for approval, but whenever a tag is submitted, the message returned is “Tag already added but thanks.” instead.
Otherwise, I really like this plug-in.
Thanks.