Add Brand Custom Taxonomy To WooCommerce Products Shortcode

The code in this download folder enables you to create a custom taxonomy named Brand which is added to the default WooCommerce Products admin menu like this:

The screenshot shows a admin link added to the WC Products menu in your WordPress Dashboard. Once clicked, you can add brand names and then assign them to single products.

You can create your brands on the Brands admin page or directly on the single Edit Product page like this :

The download folder also includes :

  • Code to create a custom class attribute for use with the default WooCommerce products shortcode
  • Code to remove “Out of Stock: Products from your products list
    Code to display your shortcodes in any hook or template file position.

Demo Video

Shows the custom products grid displaying before the single product summary when products have been assigned to a brand and are in stock. When “out of stock” and/or not assigned to a brand, products will not display in the grid.

Tested using the Twenty Twenty default theme for WordPress & the Genesis Sample theme by StudioPress.

Installation

Copy & paste the PHP code ( without the opening PHP tag ) to the end of your child themes functions file or custom functionality ( code snippets ) plugin, then go to your WordPress Dashboard > Settings > Permalinks & resave your permalinks.

You can then edit the product shortcode to add your brand names.

Download Folder

Shortcodes

Once you have installed the code, you can use the custom function from the download folder to display your products or the following shortcode in a HTML widget.

[products limit="4" columns="4" class="brand,Nike,Apple,Demo,outofstock"]

Edit this shortcode to include a comma separated list of the brands you want shown.

Related WooCommerce Code Snippets


Comments

2 responses to “Add Brand Custom Taxonomy To WooCommerce Products Shortcode”

  1. Robert Phillips-Legge Avatar
    Robert Phillips-Legge

    Is it possible to import and export to the WooCommerce brand taxonomy (your ID=109521″)

    1. If you mean products assigned to a custom taxonomy named brand, yes.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.