Custom Taxonomies

February 19th, 2010 Leave a comment Go to comments
If you are using WordPress 2.8, might I recommend Simple Taxonomies, which has a few of the features I’ve been waiting for better APIs to implement.

Download Latest Version (1.2.5) Now

WordPress provides a lot of functionality geared towards the use of generic “taxonomies”, such as Tags and Categories, but no way to manage the taxonomies themselves. The Custom Taxonomies WordPress Plugin allows you to:

  • Create custom taxonomies with admin-set names and slugs for posts, pages, or links
  • Define whether or not to accept hierarchies, descriptions, multiple selections, and/or tag-style entry
  • Manage each taxonomy’s terms in a full AJAX-interface
  • Assign terms to posts, pages, and links just as you would with categories and tags
  • Setup permalinks
  • Add widgets for your taxonomies into your site
  • NEW: Term Clouds!!
  • NEW: Support for single-selection taxonomies!!

Feedback

If you like my plugin please rate it. If you really like it (or have money to burn), please consider supporting further development by donating via PayPal

Changelog

Version 1.2.5 (2/18/10)
  • Fixed ability to remove all taxonomies from a post (thanks everyone who reported this, and Angelia for finally getting me to do this)
Version 1.2.4 (2/18/09)
  • Added “None” option to single-select dropdown (thanks nick and danf)
Version 1.2.3 (2/5/09)
  • Added term clouds!
  • Added single-selection dropdown option
  • URL parameter fix (thanks Matt)
Version 1.2.2 (1/3/09)
  • Basic backwards compatibility (thanks Hikmet)
  • Add terms bugfix (thanks Iplingo)
Version 1.2.1 (12/30/08)
  • Small fix with global variables (thanks Jorge)
Version 1.2 (12/29/08)
  • Added permalinks
  • Added ability to edit parts of taxonomies
  • DB charset bug fix
Version 1.1 (12/28/08)
  • Added widgets
Version 1.0 (12/26/08)
  • Initial release
  1. December 27th, 2008 at 20:11 | #1

    hi. Thanks for plugin

    perfect.

    Regards

  2. Jorge
    December 29th, 2008 at 15:07 | #2

    Thanks for the plugin, but the last version (1.2) has a bug:
    it disables the static front page and enable the blog as front page.

    Regards

  3. December 29th, 2008 at 18:04 | #3

    Thanks Jorge, that was a really obscure bug…all fixed!

  4. hikmet
    December 30th, 2008 at 07:31 | #4

    hi..

    i use WordPress 2.6.3 and downloaded 1.2.1 about 5 mins ago :)

    Fatal error: Call to undefined function register_column_headers() in /var/www/vhosts/xxxxxxx.com/httpdocs/wp-content/plugins/custom-taxonomies/edit-taxonomies.php on line 202

    i won’t update worpress 2.7
    in template.php of wp 2.7 register_column_headers function comes since 2.7.0

    http://wordpress.org/extend/plugins/custom-taxonomies/
    Requires WordPress Version: 2.5 or higher
    it’s wrong!.. plugin needs 2.7.0

    happy codings..

    (sorry for my bad english)

  5. December 31st, 2008 at 15:21 | #5

    Nice catch, I’ll be to test on 2.6 and add the appropriate fix. Thanks for letting me know

  6. January 2nd, 2009 at 19:41 | #6

    This is very, very, very good plugin!!! Thank you very much!!
    I can not say more, because i do not now english :)

  7. iplingo
    January 3rd, 2009 at 11:39 | #7

    Very good plugin! But I found something similar to a bug.
    In Admin navigation, clicking on the new taxonomy (under categories) take us to the taxonomy admin page, here trying to add a new term to the taxonomy returns a confirmation text without submit buttons or link to confirm/cancel.

    I use WP 2.7 italian translation.

    Thank you very much

  8. January 3rd, 2009 at 18:52 | #8

    hikmet: 1.2.2 adds some basic backwards compatibility, to the extent that I’ve tested most functionality.

    iplingo: 1.2.2 fixes your bug, thanks!

  9. iplingo
    January 6th, 2009 at 14:18 | #9

    Hi Brian, thank you again for you good work.
    How can I retrieve posts from the same term without using the widget(*)?
    I try some custom made functions, but the permalink seems not to pass the values of the taxonomy and the term.
    You can help by adding some template tags calling post/titles/taxonomy and terms with or w/o links. I see taxonomy.php can receive a generic get_$taxonomy but I’m not a serious PHP developer and I can’t understand it.
    I found a useful plugin that worth a look: organize series.
    Thank you again, bye

    (*) In readme file I found this: To display a comma-seperated list of a post or page’s taxonomy ‘thing’ in the format “Things: Thing 1, Thing 2″ use `<?php if(function_exists(‘custax_the_terms’)) custax_the_terms(‘thing’, ‘Things: ‘, ‘, ‘, ”); ?>
    But this does not seem to work for posts.

  10. January 6th, 2009 at 17:16 | #10

    Iplingo:

    There’s a function in wordpress called get_objects_in_term. See http://phpxref.com/xref/wordpress/wp-includes/taxonomy.php.source.html#l198 for details. This will return all objects (i.e. posts) associated with a given taxonomy, though you will have to format it appropriately.

  11. January 8th, 2009 at 13:28 | #11

    I have recently discovered that in WordPress 2.7 if you install the “Custom-Taxonomies” plugin this is disabling the simple way to add or remove the tags for a post. I hope you will keep working on it :)

  12. January 10th, 2009 at 03:49 | #12

    Quotes are not properly managed in Taxonomy name and plural.

    when entering xx”xx

    displays xx\’xx

  13. January 10th, 2009 at 13:41 | #13

    Looks like just what ive been looking for. Anywhere to see it in action?

  14. January 11th, 2009 at 23:10 | #14

    Christian: I can’t reproduce your issue…can you perhaps send me an email (brian AT nerdlife DOT net) so we can figure out what the problem is? Thanks!

    arena: Will be fixed in 1.2.3

    hosting: Sorry, I don’t have a demo setup and it’s not too high on the list of priorities. If I have some free time I’ll try to get one up, but there’s a lot to do development-wise.

    –Brian

  15. January 21st, 2009 at 13:12 | #15

    Hi Brian!
    I’ve got a problem with custom taxonomy widgets.

    I successfully create three taxonomy (Geography, Audience & Format) but can only add Geo widget to sidebar. Geo was created first if creation order could matter.

    If I try to add either Audience or Format widget to sidebar they disappear from installed widgets list after I press Save button.

    All taxonomies works well via direct links (http://elladaguide.ru/?audience=tourists or http://elladaguide.ru/geo/north/ for example).

    There are no errors in error log.

    Do you have any suggestion?

    Anyway, thanks a lot for the plugin – it is really one I need.
    Regards, Dmitry

  16. David
    January 22nd, 2009 at 00:21 | #16

    Hi Brian – Not certain I understand the plugin. Could I use this to create a new way to organize posts? For example, I could create an “Issues” taxonomy for a magazine site?

  17. January 23rd, 2009 at 19:28 | #17

    David: Absolutely! This is a perfect example of what my plugin can do.

  18. January 23rd, 2009 at 20:52 | #18

    Dmitri: Found the problem, if you download the development version it will be fixed. Alternatively, open up custax.class.php:

    delete line 203

    change line 215 to
    if ( !$this->widget_updated && !empty($_POST['sidebar']) ) {

    change line 243 to
    $this->widget_updated = true;

    Fix will go out with the next release.

    Thanks!

  19. January 25th, 2009 at 13:26 | #19

    A very helpfull plugin – thanks !

  20. David
    January 25th, 2009 at 14:38 | #20

    Thanks Brian – This looks incredible! As someone metioned above, it would be great to see more template tags that we non-programmer types could use.

    For example, how would I add fuction similar to wp_list_categories?

  21. January 26th, 2009 at 04:05 | #21

    Brian, thanx a lot! I will try to fix it with your directions.

    And want to give some suggestions for the further improvement. For the set of taxonomies it is really helpful to have an ability to combine selected terms with AND. This way we could build a really multidimensional infospace. Please take a look at Berkeley Flamenco search & navigation framework (http://flamenco.berkeley.edu). Your work is a right step forward to the flexible navigation, so it would be great if you wouldn’t stop just here :)

    If you need more detailed info just give me the sigh please, I will send you additional thoughts and examples.

    Regards, Dmitri

  22. January 26th, 2009 at 04:25 | #22

    Dmitri: good suggestion, I agree that it would be useful to filter by categories and tags at the same time (as one example). The problem is a lot of what I did was based on existing WP code structure. I’ll keep thinking about how I could do a nested hierarchy, but it would be an extensive change to a decent chunk of code, and probably warrants its own plugin.

    Interesting thought though, I’ll definitely keep it in mind.

  23. February 2nd, 2009 at 10:50 | #23

    Hi Brian,
    your plugin is great!
    I found two problems.
    1. It is not possible to delete all terms in a post.
    2. To use custom taxonomies in sitewide tags pages plugin for wordpress MU (http://ocaoimh.ie/2008/10/01/wordpress-mu-sitewide-tags-pages-031/), the priority of a hook is set to 9.
    custax.class.php – line 100:
    add_action(’save_post’, array(&$this, ’save’), 9);

  24. February 2nd, 2009 at 17:03 | #24

    I looked all over and can’t seem to find if you have covered this, but I would like to have my taxonomies widgets be displayed in a custom way, similar to how tag clouds are displayed, is this possible? something like this would be perfect http://ilovetypography.com/img/brand-tags.gif but if I can’t display it like that, just all the terms in line with commas separating them is great

    can this be done?

  25. February 4th, 2009 at 10:23 | #25

    @Steffen: Thanks, I’ll look into it. I don’t know exactly what you mean by #2, but I assume it has something to do with using deprecated role levels instead of names. I’ll switch it.

    @Jace: It’s on my list of things to do, definitely a high priority.

  26. nick
    February 18th, 2009 at 02:16 | #26

    I don’t know how to describe my bug, but when I assign posts to a certain taxonomy term, then click the link to get all the posts by that term, my first page with 1 or 2 posts assigned to that term works fine; with 3 or more posts assigned I get a “Not Found” with older/newer page links to the correct posts. Really weird.

    Also if I go to edit a post but DO NOT want to assign it to a taxonomy term, I’m up shit creek. The drop-down menu doesn’t have the option for NOT assigning a post a taxonomy term, or am I missing something? So by simply updating and saving a post, I’m assigning it to a taxonomy term, which I don’t necessarily want.

    Seems great, I understand this plugin, but also too buggy. I’m working on a locally compiled (localhost) WP 2.7.1/PHP 5.

  27. danf
    February 18th, 2009 at 20:49 | #27

    Hi Brian – a couple questions:
    In working with the drop-down list when assigning a taxonomy to a post, it appears that it is required to select a taxonomy, is there a way to not be forced to select a single one for each post (or should I like a ‘Uncategorized’ one first that shows as the default)?

    Also, will it handle the scenario when there are lots (hundreds) of different terms on displaying all in 1 drop-down menu? It may be hard to work with such a long list.

    Lastly, I’ve had email conversations with you in the past on wp-hackers mailing list about the ability to add custom meta-data to terms. I’ve created a plugin (based on c2c custom-fields-for-anything) that is specific to categories (the admin page just shows as part of the edit-category page), but I am now at the point where I could start creating new taxonomies and would like to have meta data associated with those. Would you be interested in collaborating on incorporating that as a feature of your plugin? (youre a much better programmer than I am :) )

  28. February 19th, 2009 at 00:09 | #28

    @nick & @danf: I added a None option and made a release.

    nick: Is that in the admin panel or on your site itself? I’m guessing on the site…either way I’ll look into it.

    danf: Regarding really long dropdowns – that is what tag-style selection will be for, it will allow an auto-completion, and will be the preferred option to the dropdown. It’s a bit of a pain to get working though. Also, I’ll shoot you an email about your feature…I worry about bloating the core goal of the plugin, but it’s something worth considering and I’d like a more detailed use case/explanation.

    Thanks guys!

  29. nick
    February 19th, 2009 at 01:32 | #29

    yeah it’s displayed on my site itself. I thought it was something I missed the first time around, so I deleted all terms, etc., uninstalled the plugin, went in fresh, then assigned one post at a time to a term, then clicked through the term from the list after each update. it was after 3 posts got assigned that I got the Not Found return. very strange. thanks for your efforts!

  30. February 19th, 2009 at 08:16 | #30

    Great plugin! I have wanted something like this for ages. I have a question about theming, though. When I want a diffent layout for a category page, I create a category.php file in my theme folder. Likewise, for tags I create a tags.php file. If I create a new taxonomy named ‘widgets’, and I create a widgets.php, the rendered page is in the default style of categories/tags, it is not themed. Should I be doing this differently, or is wordpress/the plugin not designed this way?

  31. danf
    February 19th, 2009 at 12:51 | #31

    Thanks Brian for the quick fix on adding the ‘None’ – looks to be working. I look forward to the tag-style for adding selection :)

  32. Anders
    February 19th, 2009 at 19:09 | #32

    @Brian I experienced this as well. It seems like the paging a bit buggy for listing post of a specific category. For example it doesn’t list the correct number of post. If you have 3 pages for exaple, only the fist one shows up and to see the next to you have to go to older posts. Also, when setting the wp-admin/options-reading.php to “1″, I also get a 404. Somehow the counting is off – I you set it to 100 all post are listed.

  33. danf
    March 2nd, 2009 at 10:33 | #33

    Hi Brian – How does wordpress handle custom taxonomy listing pages if permalinks are enabled? In other words, Is there a way to create a custom_taxonomy page template in our theme similar to how wordpress handles custom category templates (i.e. category-#.php where # is the category id).

    For example, if my custom taxonomy is “issue” and I have 2 terms of this custom taxonomy: Jan-09 and Feb-09. Then I have a post that is assigned to the Jan-09 issue. There are 3 different levels that I could potentially create custom template for:

    The issue listing page: http://mydomain.com/issues/
    The Jan-09/Feb-09 listing page: http://mydomain.com/issues/jan-09/
    (I don’t want to have to create a different template for each of these, just 1 that would be used for both jan/feb)

    Then the actual post: http://mydomain.com/issues/jan-09/my_jan_09_article/
    This one I’ve found code on how to handle, so am good there.

    Any help on how I could create those templates for the first 2 pages (i.e. the issue listing and the jan/feb-09 listing pages)???

    Thanks

  34. March 2nd, 2009 at 11:13 | #34

    @danf: Quotes word for word from an email I sent to another person looking for help :-P

    “If I understand you correctly, you want to use the function is_tax( $slug = ” ). is_tax() will return true if a query contains a taxonomy, while is_tax(‘foobar’) will return true if a query contains the ‘foobar’ taxonomy. So you probably want is_tax(‘issue’) or something.”

    Does that answer your question?

  35. danf
    March 2nd, 2009 at 12:50 | #35

    where would I place this code? By query you mean part of the url path? (i.e. mydomain.com/issue/ ) – right now I get a 404 when going to that url, so not sure which template page should be modified.

    Thanks

  36. danf
    March 2nd, 2009 at 12:54 | #36

    I just Darryn’s question above. My question is similar to his.

  37. danf
    March 2nd, 2009 at 16:07 | #37

    After digging in the wordpress code, I realized that wordpress does indeed handle this already. WordPress will look look for a template for categories in the following order:
    taxonomy-$taxonomy-$term.php
    taxonomy-$taxonomy.php
    taxonomy.php

    I haven’t tested this yet, but will do so and report back if it works.

  38. danf
    March 2nd, 2009 at 16:08 | #38

    danf :
    Wordpress will look look for a template for categories

    Sory, I mean taxonomies, not categories

  39. danf
    March 2nd, 2009 at 19:24 | #39

    Just an update for future reference:

    The taxonomy php naming worked perfectly. I didn’t have to add any coding or do anything. Just create a file in my theme called: taxonomy-issue.php and it gets called when visiting: http://mydomain.com/issue/jan-09/ AND http://mydomain.com/issue/feb-09/ . If I wanted a different template for just feb-09, then would create a taxonomy-issue-feb-09.php

    What I couldn’t get to work is if it is just the top-level taxonomy: /issue/ – but I could create just a page for that and use a custom page template. I noticed that categories have same problem. If using default slug of ‘category’, then http://mydomain.com/category/ will return a 404 – same as for custom taxonomies.

  40. March 3rd, 2009 at 00:13 | #40

    @danf: I see, I misunderstood your problem. Dealing with query URIs and rewrites is actually obscenely annoying in WordPress, facilitated by a bug in how WordPress handles taxonomies ( http://core.trac.wordpress.org/ticket/8731 ). Hopefully I’ll be able to solidify it in the future (though recently the WordPress folks confirmed that 2.8 will have the functionality of this plugin built in).

  41. danf
    March 3rd, 2009 at 23:15 | #41

    that’s great news about 2.8 – but I guess that puts you out of a job :)

    speaking of bugs, I just filed this one I found as a continuation of my testing with permalinks and custom taxonomies: http://core.trac.wordpress.org/ticket/9269

    basically, if you have a term of a custom taxonomy that does not have any posts associated with it, then you can’t have a listing page for that term – it will return a 404 instead of returning the proper taxonomy template file.

    So, to overcome this, you have atleast 2 options:
    1) Requires no core modification: Make sure every term has atleast 1 post associated with it.
    2) Make the core modifications I outlined in the ticket I linked to
    (I chose option 2 as I have hierarchical taxonomies so it didn’t make sense for some terms to have posts assigned to them, but I wanted to have a listing page for them that listed all the sub-terms and didn’t want to create fake posts just to assign to each term).

    Hopefully with built-in support for custom taxonomies they will fix this.

  42. Ray
    March 6th, 2009 at 15:25 | #42

    Basically what danf said, is there a way to template the top-level taxonomy?

    Also, if there is a custom taxonomy of say /genre/jazz
    and there is already a category named /jazz.
    That will conflict with one another.

    Is there a way so your plugin can separate the two?
    Or is this more of a WordPress issue?

  43. Ray
    March 6th, 2009 at 15:30 | #43

    @danf
    Re: your workaround for the top-level taxonomy styling.

    Did you implement this on your site?
    If so, did you name your page the exact, same name as the top-level taxonomy?

  44. danf
    March 6th, 2009 at 23:12 | #44

    @Ray – I actually have each of my taxonomies also associated with single category – so I am using a custom category template for my top level to list the terms, but you could also create a page for each taxonomy and use a page template. To list all the top level terms, you would use:

    get_terms($taxonomy, array(‘parent’=>0)) – then display the terms.

  45. danf
    March 6th, 2009 at 23:16 | #45

    Brian – if I have alot of terms created for a taxonomy, on the admin page for that taxonomy it will only display 6 pages worth of terms. The navigation buttons show there are more pages available, but when you click on any page > 6 it just shows an empty table.

    In the drop-down lists of terms to assign as a parent it shows the full list of terms so it knows they are there, but the listing page isn’t displaying them.

  46. danf
    March 6th, 2009 at 23:21 | #46

    correction – any page > 5 shows up blank. So page 6 and above.

  47. danf
    March 7th, 2009 at 02:19 | #47

    It looks like it may have to do with child terms as I just did it again with less data and I noticed that it broke on the page where the sub-terms begin (this time on the second page).

  48. March 12th, 2009 at 10:50 | #48

    Just downloaded. But one question: for the single post to list in what category (with links) is published in WP we use the_category(); tag. Also for specific category we can use category-x.php file with diferent template. Is it possible with this plugin?

    Many thanks.
    Mykolas

  49. danf
    March 12th, 2009 at 17:25 | #49

    Hi Mikas – you can use taxonomy-$taxonomy.php (where $taxonomy is the custom taxonomy). Or you can even go a step further with taxonomy-$taxonomy-$term.php

    See my comments above that talk a bit more about it (as well as some issues I’ve found with the wordpress template loader)

  50. March 13th, 2009 at 02:45 | #50

    Ok, I activated plugin and it broke down whole website. I’m using qTranslate and when I select EN language, I get “404 -not found” page without footer and header (those two is on different files html-footer.php and html-header.php, but get_footer() and get_header() tags are used). It happens when I select additional language (in my case /&lang=en) and it also doesn’t work gor category page.

Comment pages
1 2 3 4 146
  1. December 29th, 2008 at 18:22 | #1
  2. January 21st, 2009 at 17:46 | #2
  3. January 30th, 2009 at 18:28 | #3
  4. February 15th, 2009 at 17:28 | #4
  5. February 19th, 2009 at 05:38 | #5
  6. March 2nd, 2009 at 00:47 | #6
  7. May 26th, 2009 at 20:26 | #7
  8. November 18th, 2009 at 05:53 | #8
  9. April 27th, 2010 at 00:13 | #9
  10. June 3rd, 2010 at 02:52 | #10
  11. July 20th, 2010 at 17:26 | #11
  12. January 14th, 2012 at 12:38 | #12