Skip to content

Instantly share code, notes, and snippets.

@shelleyhoward
Created February 4, 2014 15:58
Show Gist options
  • Save shelleyhoward/8806396 to your computer and use it in GitHub Desktop.
Save shelleyhoward/8806396 to your computer and use it in GitHub Desktop.
Use categories and tags on media
<?php
/*
Plugin Name: Media Categories and Tags
Description: Plugin adds the ability to use categories and tags on media
Version: 1.0
Author: Shelley Howard
Author URI: http://shelleyhoward.com
*/
// apply categories to media attachments
function sh_add_categories_to_attachments() {
register_taxonomy_for_object_type( 'category', 'attachment' );
}
add_action( 'init' , 'sh_add_categories_to_attachments' );
// apply tags to media attachments
function sh_add_tags_to_attachments() {
register_taxonomy_for_object_type( 'post_tag', 'attachment' );
}
add_action( 'init' , 'sh_add_tags_to_attachments' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment