cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

How To Categorize Media Attachments In WordPress

Have you ever had to dig  through hundreds of media files you’ve uploaded in WordPress to find one particular image or video? Wouldn’t it be nice if you could only categorize them to make locating them easier?  Sadly, assigning categories to any of your uploaded media isn’t one of the features that are included in WordPress’ Media Editing screen. But then what’s stopping us from creating one?

In one of Rachel McCollin’s articles in WP Tuts+, she shows us a way to add such a feature simply by adding some simple code to your theme functions file (or to a plugin). For starters, there are a few things you’re going to need in order to accomplish this. These are:

  • A development installation of WordPress.
  • An access to your theme’s function file or if you prefer creating a plugin, an FTP access to the server.
  • A text editor.

Once you’re certain you have all these then you can proceed with caution.

The first will require you to open your functions file (or create a plugin file) and add the following code to it which contains the register_taxonomy_for_object_type() function:

function wptp_add_categories_to_attachments() {
 register_taxonomy_for_object_type( 'category', 'attachment' );
}
add_action( 'init' , 'wptp_add_categories_to_attachments' );     

Save the file and refresh the Media Editing screen. If done correctly, you should then see a “Categories” column (see below image). And that’s it! You’re done.


Image source: wp.tutsplus

Aside from adding categories to your media attachments, Rachel also teaches you how to apply tags and custom taxonomies. You can read and find out how it’s all done right here.

Related Posts

Themeum’s Flat Theme Multipurpose WordPress Theme

Weblizar Premium Responsive Theme

Automattic Buys WooCommerce Plugin for WordPress

Localbiz Business Theme for WordPress