Media Categories 1.4 – Limitless Taxonomy

Yesterday a co-worker expressed a need to use the Media Categories plugin with not just a custom taxonomy, but with multiple taxonomies. So I spent last night at the office until around 9:45PM working on Media Categories 1.4.

Not to get bogged down in overly technical talk here, since I know that a lot of the users of this plugin are not developers. The main change in this release is that the class is instantiated as an object rather than called statically. All (except a few) references within the class have been changed from static references to objective references.

If you don’t know what the heck I’m talking about, thats ok. All it means is that developers can new create any number of instances of Media Categories checkboxes, for any number of taxonomies.


Lets say you already use Media Categories for the “Category” taxonomy, but now find yourself needing to apply a new custom taxonomy – lets call it ‘genre’. All a developer needs to do is create a new object, and pass ‘genre’ as the parameter.

$genre = new Media_Categories('genre');

Thats it! As long as that taxonomy exists, and has all the proper “labels” set up, Media Categories 1.4 will add a second metabox to media with all the proper labels for pluralization and context.

Filtering a Taxonomy

Since the release of Media Categories 1.3, which was less than a month ago – developers have been able to change the taxonomy being applied to media by making use of the `mc_taxonomy` filter. This is still the case, but theres to it now that there might be any number of taxonomies applied to attachments.

If you simply return ‘your_taxonomy’ to the filter without any conditions, you will over ride all instances of Media Categories in use – so to avoid that, developers need to check the value of the current taxonomy before modifying it.

add_filter('mc_taxonomy', 'custom_taxonomy_metabox');
function custom_taxonomy_metabox($taxonomy){
if($taxonomy == 'category'){
$taxonomy = 'custom_taxonomy';
return $taxonomy;
Thats all, nothing too bad - just be sure to conditionally check for the specific taxonomy you want to replace.
Please let me know how this works for everyone. Enjoy!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s