Advertisement
sayful

WP Taxonomy

Jan 19th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2. /************************************************************************************
  3. * Here's an example of registering a "people_cat" taxonomy:
  4. * To register a taxonomy, you use the register_taxonomy() function.
  5. * The "people" taxonomy is defined. It's defined to work for posts.
  6. * A rewrite slug is defined to make the url into '/person/' instead of '/people/'.
  7. *The capabilities line is optional. Without it, WordPress will default capabilities to the same users as posts. As shown above, this will allow any user with the custom "edit_guides" capability to assign the taxonomy to a post and any user with the custom "publish_guides" capability to create new taxonomy items.
  8. *************************************************************************************/
  9. function themename_custom_taxonomy() {
  10.     // create a new taxonomy
  11.     register_taxonomy(
  12.         'portfolio_cat',        // must not contain capital letters or spaces
  13.         'post',         // (post/custom post) type name
  14.         array(
  15.                 'hierarchical' => true,
  16.                 'label' => 'Portfolio Categories', //Display Name
  17.                 'query_var' => true,
  18.                 'rewrite' => array('slug' => 'portfolio-category')
  19.             )
  20.     );
  21. }
  22. add_action( 'init', 'themename_custom_taxonomy' );
  23.  
  24. /************************************************************************************
  25. Usage of Custom Taxonomy
  26. *************************************************************************************/
  27. 'portfolio_cat' => 'Feature';   //
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement