Support » Plugins » style tags/categories?

  • has anyone written a WP plugin to make categorization more like style tagging?
    at the most basic i’m just looking for a text field on the posting screen where categories can be typed in as either a comma or space separated list, and are auto created if they don’t exist. (i’ve got some code to do auto category creation in my wp-aggregator if anyone wants a jump start)
    future refinements could be added (e.g. support for “related tags” ala
    anyone done it, or interested in doing it?

Viewing 13 replies - 1 through 13 (of 13 total)
  • I was thinking of this myself, but decided to just tinker with the existing categories, but call them “keywords”. I prefer that, since I find categorization of posts difficult. Whether the logic is really all that different, I have no idea, but that works for my brain.
    I’d be interested in your auto-generate non-existing categories though. 🙂

    sunshine, i think the underlying implementation would be largely identical, its more of a UI question, exception for the auto-generation of categories.
    the following code is what I use in wp-rss-aggregate, it takes a list of category names, and returns a list of category ids, first creating any which don’t already exist. (i’m not sure how well pasting in a large code block is going to work, if it gets munged you can find it at the above url)

    // look up (and create) category ids from a list of categories
    function lookup_categories ($wpdb, $cats) {
    if ( !count($cats) ) {
    return array();
    # i'd kill for a decent map function in PHP
    # but that would require functiosn to be first class object, or at least
    # coderef support
    $cat_strs = array();
    foreach ( $cats as $c ) {
    $c = $wpdb->escape($c); $c = "'$c'";
    array_push($cat_strs, $c);
    $cat_sql = join(',', $cat_strs);
    $sql = "SELECT cat_ID,cat_name from $wpdb->categories WHERE cat_name IN ($cat_sql)";
    $results = $wpdb->get_results($sql);
    $cat_ids = array();
    $cat_found = array();
    foreach ( $results as $row ) {
    array_push($cat_ids, $row->cat_ID);
    array_push($cat_found, $row->cat_name);
    $cat_unknown = array_diff($cats, $cat_found);
    if ( count($cat_unknown) ) {
    $sql = "INSERT INTO $wpdb->categories (cat_name, category_nicename)
    VALUES ('%s', '%s')";
    foreach ( $cat_unknown as $new_cat ) {
    $nice_cat = sanitize_title($new_cat);
    $wpdb->query(sprintf($sql, $new_cat, $nice_cat));
    array_push($cat_ids, mysql_insert_id ($wpdb->dbh) );
    return $cat_ids;

    That’s some nice code there. 🙂 Could be made ever-so-slightly faster by using [] instead of array_push(), but I don’t think the speed would be much different, right?
    Thanks for sharing, kellan. I’ll have to try and corner someone — a few peeps will take suggestions for plugins, etc, so maybe we can smile sweetly and get it packaged up nicely into the admin post ui. 🙂

    I’d be happy if in the “Category” section of the post page there were three empty spaces (text boxes) for new categories.

    Ooh, this is something I’d really like to see too. I’m all for some sort of ‘on the fly’ category/tag creation…

    Me too!

    I did some rough work on enabling this tonight. It works, and I’m pretty happy with it, but its currently a direct patch rather then a plugin.
    I put up some thoughts on tagging in general, and some notes on the patch.
    Its about 2am here, so it might not be coherent.

    Thanks so much for sharing, kellan. I’ll be trying this out as soon as I can and give you feedback, if you’d like?

    I think I have a fairly useful solution that I just finished today:

    latest version of tags code is at:

    mostly a plugin this time, though i had to add a few “missing” hooks

    I’ve been fooling around with Kellan’s “mostly” plugin, and am really happy with the way it works. However, I noticed that when the plugin is activated and I make any changes to my static pages, I get the following errors:

    Warning: Invalid argument supplied for foreach() in /wp-includes/template-functions-category.php on line 410
    Warning: in_array(): Wrong datatype for second argument in /wp-includes/template-functions-category.php on line 414

    So, to avoid the errors when updating static pages, I simply turn off Kellan’s plugin, make the changes, and then turn it back on again.

    I’m setting up internal keywords/tags as supplements to categories (and as a way to unify my three WP installs) thanks to Jerome’s Keywords: And I am so thankful…!

    Take a look at Felix Wong’s Tags plugin. You can find it on his site or in I am still having some minor troubles with it, but it is going to be really nice when it finally works. It works great on his site however so you can see it in action there.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘ style tags/categories?’ is closed to new replies.