Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->create_cpt('product', 'Products', 'Product', false, 'product');
- $this->create_taxonomy('surface', 'product', __('Surface'), __('Surfaces'));
- $this->create_taxonomy('products', 'product', __('Related Product'), __('Related Products'));
- function create_taxonomy($tax, $post_type, $singular_name, $plural_name, $hierarchical = true, $show_ui = true) {
- $labels = array(
- 'name' => _x( $plural_name, 'taxonomy general name' ),
- 'singular_name' => __( $singular_name, 'taxonomy singular name' ),
- 'search_items' => __( 'Search ' . $plural_name ),
- 'all_items' => __( 'All ' . $plural_name ),
- 'parent_item' => __( 'Parent ' . $singular_name ),
- 'parent_item_colon' => __( 'Parent ' . $singular_name . ':' ),
- 'edit_item' => __( 'Edit ' . $singular_name ),
- 'update_item' => __( 'Update ' . $singular_name ),
- 'add_new_item' => __( 'Add New ' . $singular_name ),
- 'new_item_name' => __( 'New ' . $singular_name . ' Name' ),
- );
- $args = array(
- 'hierarchical' => $hierarchical,
- 'labels' => $labels,
- 'show_ui' => $show_ui
- );
- register_taxonomy( $tax, $post_type, $args);
- }
- 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')) {
- $labels = array(
- 'name' => __($plural_name, 'post type general name'),
- 'singular_name' => __($singular_name, 'post type singular name'),
- 'add_new' => __('Add new ' . $singular_name, $post_type),
- 'add_new_item' => __('Add new ' . $singular_name),
- 'edit_item' => __('Edit ' . $plural_name),
- 'new_item' => __('New ' . $singular_name),
- 'view_item' => __('View ' . $singular_name),
- 'search_items' => __('Search ' . $plural_name),
- 'not_found' => __('No ' . $plural_name . ' found'),
- 'not_found_in_trash' => __('No ' . $plural_name . ' found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- '_builtin' => false,
- 'query_var' => true,
- 'hierarchical' => $hierarchical,
- 'rewrite' => !empty($slug) ? array('slug' => $slug) : false,
- 'capability_type' => $capability,
- 'menu_position' => $menu_position,
- 'supports' => $supports
- );
- register_post_type($post_type, $args);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement