kalponikoronno

Wordpress Custom Taxonomy

Aug 29th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. function pages_taxonomy() {
  3.     register_taxonomy(
  4.         'service_cat',  //1. The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). example: portfolio_cat
  5.         'services-items',                  //2. post type name  , custom post id (register_post_type id): example: news_sites
  6.         array(
  7.             'hierarchical'          => true,
  8.             'label'                         => 'Service Category',  //3. Display name
  9.             'query_var'             => true,
  10.             'capabilities' => array(
  11.                 'manage__terms' => 'edit_posts',
  12.                 'edit_terms' => 'manage_categories',
  13.                 'delete_terms' => 'manage_categories',
  14.                 'assign_terms' => 'edit_posts'
  15.             ),         
  16.             'rewrite'                       => array(
  17.                     'slug'                  => 'service-category', // 4. This controls the base slug that will display before each term
  18.                     'with_front'    => false // Don't display the category base before
  19.                     )
  20.             )
  21.     );
  22. }
  23. add_action( 'init', 'pages_taxonomy');        
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment