Add Tag or Taxonomy in WordPress Media with Filter Option

You might be a photographer or or run a photography blog. Then it is obvious that you want to give credit to all photographers. In WordPress you can do this easily. You just need to add a new tag or taxonomy like “Tag Photographer” and tag the name after uploading the image. Lets see how we can do this.
First of all we need to create a taxonomy for the attachment post type, which is WP media post type.

function my_custom_taxonomies_photographer()
$labels = array(
'name' => 'Tag Photographers ',
'singular_name' => 'Tag Photographer',
'search_items' => 'Search Photographers',
'all_items' => 'All Photographers',
'parent_item' => 'Parent Photographer',
'parent_item_colon' => 'Parent Photographer:',
'edit_item' => 'Edit Photographer',
'update_item' => 'Update Photographer',
'add_new_item' => 'Add New Photographer',
'new_item_name' => 'New Photographer Name',
'menu_name' => 'Tag Photographer',

$args = array(
‘hierarchical’ => false,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘my-photographers’ ),

register_taxonomy( ‘my-photographers’, array( ‘attachment’ ), $args );

add_action( ‘init’, ‘my_custom_taxonomies_photographer’ );

Just add the code in your theme’s functions.php file and now go to media list and try to edit a media. You will see the tag box to tag photographer.





Posted on May 2, 2015, in Uncategorized and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google+ photo

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

Twitter picture

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

Facebook photo

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


Connecting to %s

%d bloggers like this: