Product filtering by Custom Taxonomy (manually)

September 8, 2020

WooCommerce Custom Taxonomy is a feature that allows you to display additional product data based on class. This could be the color, size, or style of your product.

Most WooСommerce clients use CPT UI and ACF plugins to create a custom taxonomy. Read this article to learn how to create taxonomies using these plugins and filter by them with the Product Table plugin by WooBeWoo.

But is it possible to create custom taxonomies and custom fields without these plugins? Definitely yes, and this article will help you create your own taxonomies for WooCommerce products manually using code.

Product filtering by Custom Taxonomy

 Using the plugin is the easiest way to create a custom taxonomy and get a toolbox for working with custom content types.

However, if you choose manually creation of a Custom Taxonomy, this article will help you do just that.

 Step 1. Copy the code to functions.php file

 Just add the following code to your theme’s functions.php file.

Below we have provided an example of such code:

 

/* 

 * Add custom taxonomy

 * https://developer.wordpress.org/reference/functions/register_taxonomy/

 */

$args = array(

                                ‘hierarchical’          => true,

                                ‘labels’                => array(

                                            ‘name’                       => _x( ‘Taxonomy Name’, ‘taxonomy general name’, ‘THEME_DOMAIN’ ),

                                            ‘singular_name’              => _x( ‘Singular Name’, ‘taxonomy singular name’, ‘THEME_DOMAIN’ ),

                                            ‘search_items’               => __( ‘Search’, ‘THEME_DOMAIN’ ),

                                            ‘popular_items’              => __( ‘Popular’, ‘THEME_DOMAIN’ ),

                                            ‘all_items’                  => __( ‘All’, ‘THEME_DOMAIN’ ),

                                            ‘parent_item’                => null,

                                            ‘parent_item_colon’          => null,

                                            ‘edit_item’                  => __( ‘Edit’, ‘THEME_DOMAIN’ ),

                                            ‘update_item’                => __( ‘Update’, ‘THEME_DOMAIN’ ),

                                            ‘add_new_item’               => __( ‘Add new’, ‘THEME_DOMAIN’ ),

                                            ‘new_item_name’              => __( ‘New’, ‘THEME_DOMAIN’ ),

                                            ‘add_or_remove_items’        => __( ‘Add or remove’, ‘THEME_DOMAIN’ ),

                                            ‘menu_name’                  => __( ‘Taxonomy Name’, ‘THEME_DOMAIN’ ),

                                ),

                                ‘show_ui’               => true,

                                ‘show_admin_column’     => true,

                                ‘update_count_callback’ => ‘_update_post_term_count’,

                                ‘query_var’             => true,

                                ‘rewrite’               => array( ‘slug’ => ‘taxonomy-slug’ ),

                     );

                     register_taxonomy( ‘taxonomy_name’, ‘product’, $args );

 

Step 2. Make Custom Taxonomy

 Let’s assume that you have already installed WooCommerce and created the products you need.

After you have added the code, a tab for adding taxonomies will appear in the admin panel of your WordPress website, namely in the sub-items of the Products section.

Open this tab. Here you can add a new taxonomy:

-for that, just enter the title, slug, parent taxonomy, description, and click add.

For example, we have added several types of textile for a clothing store.

 Custom Taxonomy

Step 3. Assign taxonomy to your product

Now when you have created a taxonomy, in the product editor you can assign it to the corresponding product.

Go to Products and check the box next to the relevant taxonomy

Edit Product

Step 4. Add a custom taxonomy to the product filter.

The good news is that there is a handy WooCommerce Product Filter by WooBeWoo plugin for filtering products based on additional data such as custom WooCommerce taxonomies.

After you have installed and activated the plugin, proceed to edit the desired product filter or create a new one.

Now when editing the product filter:

-add filter by attributes,

-the attribute selection field, select your taxonomy, after which it will be displayed in the preview,

-now in the preview, you will see the filter for this type of taxonomy, after which you can fully customize its parameters and design. Explore our detailed documentation to find out more.

 Add a custom taxonomy to the product filter.

Working on the Frontend

WooCommerce Product Filter by WooBeWoo is the perfect way to display products with additional information as everything is presented in a structured tabular format. You can add a product filter to any WordPress page, your main WooCommerce store, or product category pages. Products can be filtered by taxonomy with handy checkboxes, dropdowns, buttons, and many other display methods.

Still have any questions? Read our detailed documentation or contact us and we will be glad to help you.

Leave a Reply

Your email address will not be published. Required fields are marked *

Buy Now Bundle and save over 60%

Buy now