Saturday, May 2, 2015

Add Tag or Taxonomy in WordPress Media with Filter Option

Via:MyTutorialGuru.com

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.


tag-to-wordpress-media


 


 

No comments:

Post a Comment