Advertisement
Guest User

Untitled

a guest
Nov 17th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.28 KB | None | 0 0
  1. function register_product() {
  2.     $labels = array(
  3.         'name' => _x('Catalog', 'post type general name','LADS'),
  4.         'singular_name' => _x('Product', 'post type singular name','LADS'),
  5.         'add_new' => _x('Add','LADS'),
  6.         'add_new_item' => __('Add','LADS'),
  7.         'edit_item' => __('Edit','LADS'),
  8.         'new_item' => __('Add','LADS'),
  9.         'all_items' => __('All','LADS'),
  10.         'view_item' => __('View','LADS'),
  11.         'search_items' => __('Search','LADS'),
  12.         'not_found' =>  __('Nothing Found','LADS'),
  13.         'not_found_in_trash' => __('Nothing Found','LADS'),
  14.         'parent_item_colon' => ''
  15.     );
  16.     $args = array(
  17.         'labels' => $labels,
  18.         'public' => true,
  19.         'publicly_queryable' => true,
  20.         'show_ui' => true,
  21.         'query_var' => true,
  22.         'rewrite' => array( 'slug' => 'catalog' ),
  23.         'capability_type' => 'post',
  24.         'hierarchical' => false,
  25.         'menu_position' => null,
  26.         'taxonomies' => 'product_category',
  27.         'supports' => array('title','editor','thumbnail','excerpt','comments','revisions','custom-fields')
  28.     );
  29.     register_post_type( 'product' , $args );
  30. }
  31. add_action('init', 'register_product');
  32.  
  33.  
  34. function create_product_taxonomies() {
  35.  
  36.     // product category taxonomy
  37.     $labels = array(
  38.         'name'              => _x( 'Categories', 'taxonomy general name' ),
  39.         'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
  40.         'search_items'      => __( 'Search'),
  41.         'all_items'         => __( 'All' ),
  42.         'parent_item'       => __( 'Parent' ),
  43.         'parent_item_colon' => __( 'Parent'),
  44.         'edit_item'         => __( 'Edit' ),
  45.         'update_item'       => __( 'Edit' ),
  46.         'add_new_item'      => __( 'Add new' ),
  47.         'new_item_name'     => __( 'Add new' ),
  48.         'menu_name'         => __( 'Categories' ),
  49.     );
  50.  
  51.     $args = array(
  52.         'hierarchical'      => true,
  53.         'labels'            => $labels,
  54.         'show_ui'           => true,
  55.         'show_admin_column' => true,
  56.         'query_var'         => true,
  57.         'show_in_nav_menus' => true,
  58.         'rewrite'           => array( 'slug' => 'k' )
  59.     );
  60.     register_taxonomy( 'product_category', array( 'product', 'page'), $args );
  61.  
  62.     // product brand taxonomy
  63.     $labels = array(
  64.         'name'              => _x( 'Producers', 'taxonomy general name' ),
  65.         'singular_name'     => _x( 'Producer', 'taxonomy singular name' ),
  66.         'search_items'      => __( 'Search'),
  67.         'all_items'         => __( 'All' ),
  68.         'parent_item'       => __( 'Parent' ),
  69.         'parent_item_colon' => __( 'Parent'),
  70.         'edit_item'         => __( 'Edit' ),
  71.         'update_item'       => __( 'Edit' ),
  72.         'add_new_item'      => __( 'Add new' ),
  73.         'new_item_name'     => __( 'Add new' ),
  74.         'menu_name'         => __( 'Producers' ),
  75.     );
  76.     $args = array(
  77.         'hierarchical'      => true,
  78.         'labels'            => $labels,
  79.         'show_ui'           => true,
  80.         'show_admin_column' => true,
  81.         'query_var'         => true,
  82.         'rewrite'           => false,
  83.     );
  84.     register_taxonomy('product_brand', array( 'product' ), $args );
  85. }
  86.  
  87. add_action( 'init', 'create_product_taxonomies', 0 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement