Advertisement
Guest User

Untitled

a guest
Dec 29th, 2010
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.48 KB | None | 0 0
  1. $this->create_cpt('product', 'Products', 'Product', false, 'product');
  2.  
  3. $this->create_taxonomy('surface', 'product', __('Surface'), __('Surfaces'));
  4. $this->create_taxonomy('products', 'product', __('Related Product'), __('Related Products'));
  5.  
  6. function create_taxonomy($tax, $post_type, $singular_name, $plural_name, $hierarchical = true, $show_ui = true) {
  7.             $labels = array(
  8.                 'name' => _x( $plural_name, 'taxonomy general name' ),
  9.                 'singular_name' => __( $singular_name, 'taxonomy singular name' ),
  10.                 'search_items' =>  __( 'Search ' . $plural_name ),
  11.                 'all_items' => __( 'All ' . $plural_name ),
  12.                 'parent_item' => __( 'Parent ' . $singular_name ),
  13.                 'parent_item_colon' => __( 'Parent ' . $singular_name . ':' ),
  14.                 'edit_item' => __( 'Edit ' . $singular_name ),
  15.                 'update_item' => __( 'Update ' . $singular_name ),
  16.                 'add_new_item' => __( 'Add New ' . $singular_name ),
  17.                 'new_item_name' => __( 'New ' . $singular_name . ' Name' ),
  18.             );
  19.            
  20.             $args = array(
  21.                 'hierarchical' => $hierarchical,
  22.                 'labels' => $labels,
  23.                 'show_ui' => $show_ui
  24.             );
  25.            
  26.             register_taxonomy( $tax, $post_type, $args);
  27.            
  28.         }
  29.  
  30. function create_cpt($post_type, $plural_name, $singular_name, $hierarchical = false, $slug = '', $capability = 'post', $menu_position = 5, $supports = array('title','editor','excerpt','thumbnail','custom-fields')) {
  31.             $labels = array(
  32.                 'name' => __($plural_name, 'post type general name'),
  33.                 'singular_name' => __($singular_name, 'post type singular name'),
  34.                 'add_new' => __('Add new ' . $singular_name, $post_type),
  35.                 'add_new_item' => __('Add new ' . $singular_name),
  36.                 'edit_item' => __('Edit ' . $plural_name),
  37.                 'new_item' => __('New ' . $singular_name),
  38.                 'view_item' => __('View ' . $singular_name),
  39.                 'search_items' => __('Search ' . $plural_name),
  40.                 'not_found' =>  __('No ' . $plural_name . ' found'),
  41.                 'not_found_in_trash' => __('No ' . $plural_name . ' found in Trash'),
  42.                 'parent_item_colon' => ''
  43.             );
  44.  
  45.             $args = array(
  46.                 'labels' => $labels,
  47.                 'public' => true,
  48.                 'publicly_queryable' => true,
  49.                 'show_ui' => true,
  50.                 '_builtin' => false,
  51.                 'query_var' => true,
  52.                 'hierarchical' => $hierarchical,
  53.                 'rewrite' => !empty($slug) ? array('slug' => $slug) : false,
  54.                 'capability_type' => $capability,
  55.                 'menu_position' => $menu_position,
  56.                 'supports' => $supports
  57.             );
  58.    
  59.             register_post_type($post_type, $args);
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement