Advertisement
Guest User

Image Taxonomy

a guest
Nov 25th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. /*
  3.  * Custom Taxonomy
  4.  */
  5.  
  6. // Custom taxonomy for media attachments, acts like Categories
  7. function kebo_create_image_taxonomy()
  8. {
  9.   // Add new taxonomy, make it hierarchical (like categories)
  10.   $labels = array(
  11.     'name'                => _x( 'Categories', 'kebo' ),
  12.     'singular_name'       => _x( 'Category', 'kebo' ),
  13.     'search_items'        => __( 'Search Categories' ),
  14.     'all_items'           => __( 'All Categories' ),
  15.     'parent_item'         => __( 'Parent Category' ),
  16.     'parent_item_colon'   => __( 'Parent Category:' ),
  17.     'edit_item'           => __( 'Edit Category' ),
  18.     'update_item'         => __( 'Update Category' ),
  19.     'add_new_item'        => __( 'Add New Category' ),
  20.     'new_item_name'       => __( 'New Category Name' ),
  21.     'menu_name'           => __( 'Categories' )
  22.   );    
  23.  
  24.   $args = array(
  25.     'hierarchical'        => true,
  26.     'labels'              => $labels,
  27.     'show_ui'             => true,
  28.     'show_admin_column'   => true,
  29.     'query_var'           => true,
  30.     'show_in_nav_menus'   => false,
  31.     'show_tagcloud'       => false,
  32.     'rewrite'             => array(
  33.         'slug' => 'media-category',
  34.         'with_front' => false,
  35.     )
  36.   );
  37.  
  38.   register_taxonomy( 'media-category', 'attachment', $args );
  39.  
  40. }
  41. add_action( 'init', 'kebo_create_image_taxonomy' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement