Is well know that the WooCommerce Product Brands plugins allow you to create a brand taxonomy for your shop. But I personally think that pay 29 USD for this simple function is excessive.
So every time I had to include this feature in my sites I include my own code, which is pretty simple actually. So now, without further ado, I’ll show you how to create a new brand taxonomy for your WooCommerce theme.
Products Brand
You only need to include this code in your functions.php or your plugin’s files and a new taxonomy will be included inside your Products menu as you can see in the image below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
add_filter('register_taxonomy_args', 'wprocks_product_brand', 10, 3); function wprocks_product_brand($args, $taxonomy, $object_type) { if ($taxonomy == 'brand') { $args = array( 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Brands', 'wprocks'), 'labels' => array( 'name' => __('Brands', 'wprocks'), 'singular_name' => __('Brand', 'wprocks'), 'search_items' => __('Search Brands', 'wprocks'), 'all_items' => __('All Brands', 'wprocks'), 'parent_item' => __('Parent Brand', 'wprocks'), 'parent_item_colon' => __('Parent Brand:', 'wprocks'), 'edit_item' => __('Edit Brand', 'wprocks'), 'update_item' => __('Update Brand', 'wprocks'), 'add_new_item' => __('Add New Brand', 'wprocks'), 'new_item_name' => __('New Brand Name', 'wprocks') ), 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'capabilities' => array( 'manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms' ), 'rewrite' => array( 'slug' => 'marca', 'with_front' => false, 'hierarchical' => true ) ); } return $args; } |