Advertisement
manchumahara

Custom post type and custom taxonomy in wordpress

Aug 1st, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. add_action( 'init', 'cb_create_custom_postype_taxonomies', 0 );  // call function to create custom post types and taxonomy
  2.  
  3. function cb_create_custom_postype_taxonomies(){
  4.     global $wp_rewrite;
  5.  
  6. //create custom post types
  7.     register_post_type('product',
  8.             array(
  9.                 'label' => 'Product','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,
  10.                 'rewrite' => array('slug' => 'products', 'with_front' => true),
  11.                 //'rewrite' => false,
  12.                 'query_var' => true,
  13.                 'supports' => array('title','editor','trackbacks','custom-fields','comments','thumbnail','author'),
  14.                 'labels' => array (
  15.                       'name' => 'Products',
  16.                       'singular_name' => 'Product',
  17.                       'menu_name' => 'Products',
  18.                       'add_new' => 'Add Product',
  19.                       'add_new_item' => 'Add New product',
  20.                       'edit' => 'Edit',
  21.                       'edit_item' => 'Edit Job',
  22.                       'new_item' => 'New Job',
  23.                       'view' => 'View Job',
  24.                       'view_item' => 'View Job',
  25.                       'search_items' => 'Search Jobs',
  26.                       'not_found' => 'No Jobs Found',
  27.                       'not_found_in_trash' => 'No Jobs Found in Trash'
  28.                      
  29.                 ),
  30.             )
  31.     );//end register custom post type Products
  32.  
  33.     //create custom taxonomy  and associate with post type
  34.  
  35.    register_taxonomy('installtype',
  36.             array (  0 => 'product',),
  37.             array( 'hierarchical' => true,
  38.                 'label' => 'Installation Types','show_ui' => true,'query_var' => true,
  39.                 'rewrite' => array('slug' => 'installtypes'),'singular_label' => 'Installation Type') );
  40.  
  41.  
  42.  
  43.        
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement