Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
How it is possible to use taxonomies on attachments?

I know this has been a long debated issue with WP, but I was hoping that since the 3.5 upgrade, there has been some progress in categorizing images in the Media Library.

Really, what I am hoping to accomplish is creating a set of categories for the images in the Media Library, and then assigning the current images, or future images, to those categories.

Then, later down the road I could call them in a page template based on their category. Any ideas WPA?

Many thanks.

share|improve this question
add comment

marked as duplicate by brasofilo, toscho Dec 28 '12 at 22:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 1 down vote accepted

See the question / answer on this link. The answer have 2 different solutions, easy with default categories and taxonomies and also a solution with custom taxonomies only for media.

share|improve this answer
1  
I'm being lousy for checking for duplicates, it seems that they are exact, I'll vote to close this one. –  brasofilo Dec 28 '12 at 21:32
    
No problem, the question is very often, duplicate with different words. Not easy for moderators. Best for you. –  bueltge Dec 28 '12 at 21:39
    
Appreciate the help fellas. I just never associated images/media = attachments, simply because you can just upload media through the library and never use the post editor to do so. I dunno, either way, this is what I'm looking for. Many thanks! –  RCNeil Dec 29 '12 at 1:15
add comment

A starting point, adding the default category to the attachment post type:

add_action( 'init', 'wpse_77550_media_categories' );

function wpse_77550_media_categories()
{   
    register_taxonomy_for_object_type( 'category', 'attachment' );
}

Or adding a custom taxonomy to the attachment post type (not sure why the taxonomy doesn't show up in the Media menu -show_ui=>true-, although the meta box shows up when editing an attachment):

add_action( 'admin_init', 'wpse_77550_media_taxonomy' );

function wpse_77550_media_taxonomy()
{   
    $labels = array(
        'name' => _x( 'Genres', 'taxonomy general name' ),
        'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Genres' ),
        'all_items' => __( 'All Genres' ),
        'parent_item' => __( 'Parent Genre' ),
        'parent_item_colon' => __( 'Parent Genre:' ),
        'edit_item' => __( 'Edit Genre' ), 
        'update_item' => __( 'Update Genre' ),
        'add_new_item' => __( 'Add New Genre' ),
        'new_item_name' => __( 'New Genre Name' ),
        'menu_name' => __( 'Genre' ),
      );    

      register_taxonomy('genre','attachment', array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'genre' ),
      ));
}

Reference:
How To: Add Taxonomies to Your Custom Post Types in WordPress

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.