While this may be a fringe case, I felt the need to document this anyways.
I recently did a site where the client would sell products online, but also have a separate products section showing non-sellable items. What this means is needed a “Products” section on top of the built in products custom post type woocommerce adds. One solution I found was to change the labels for Woocommerce:
1 2 3 4 5 6 | add_filter( 'woocommerce_register_post_type_product', 'nk_custom_post_type_label_woo' ); function nk_custom_post_type_label_woo( $args ){ $labels = nk_get_cpt_labels('Online Product','Online Shop'); $args['labels'] = $labels; return $args; } |
This just hooks in to the label outputs for the products CPT from Woocommerce and generates our own. The nk_get_cpt_labels function is just a helper function I use to output these quickly:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function nk_get_cpt_labels($single,$plural){ $arr = array( 'name' => $plural, 'singular_name' => $single, 'menu_name' => $plural, 'add_new' => 'Add '.$single, 'add_new_item' => 'Add New '.$single, 'edit' => 'Edit', 'edit_item' => 'Edit '.$single, 'new_item' => 'New '.$single, 'view' => 'View '.$plural, 'view_item' => 'View '.$single, 'search_items' => 'Search '.$plural, 'not_found' => 'No '.$plural.' Found', 'not_found_in_trash' => 'No '.$plural.' Found in Trash', 'parent' => 'Parent '.$single ); return $arr; } |
Now after I register my own custom post type of products I end up with the backend menu of: