Below, you’ll find a detailed guide on how to add the Tabbed Category Product Listing for Woocommerce Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Tabbed Category Product Listing for Woocommerce Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Tabbed Category Product Listing for Woocommerce Plugin and the shortcodes it provides:

"Tabbed Category Product Listing for Woocommerce is a powerful plugin that enhances your ecommerce experience. It simplifies product categorization and listing, making navigation easier for your customers."
- [wtcpl-product-cat]
Tabbed Category Product Listing for Woocommerce [wtcpl-product-cat] Shortcode
The Woo-Tabbed-Category-Product-Listing plugin shortcode, ‘wtcpl-product-cat’, dynamically loads products based on selected categories. It organizes products into tabs for each category, enhancing user navigation. This shortcode also provides options to control product display such as the number of products per page, column numbers, and whether to show empty categories. It also allows customization of the category order.
Shortcode: [wtcpl-product-cat]
Examples and Usage
Basic example – A simple usage of the shortcode to load products based on the defined settings in the plugin’s options.
[wtcpl-product-cat]
PHP Function Code
In case you have difficulties debugging what causing issues with [wtcpl-product-cat]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('wtcpl-product-cat', 'wtcpl_load_products');
Shortcode PHP function:
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | function wtcpl_load_products() { $qc_woo_tabbed_shortcode_preview = get_option( 'qc_woo_tabbed_shortcode_preview' ); if ( $qc_woo_tabbed_shortcode_preview != 'enable' ){ if (is_admin()) { return ; } } // if (!is_admin()) { ob_start(); $product_number = esc_attr(get_option( 'product_number' )); $column_number = esc_attr(get_option( 'column_number' )); $qc_woo_tabbed_show_empty_category = esc_attr(get_option( 'qc_woo_tabbed_show_empty_category' )) == 'enable' ? 0 : 1; wtcpl_plugin_scripts(); wtcpl_scroll_to_scripts(); wtcpl_plugin_styles(); ?> <div class = "wtcpl_container" > <div id= "nav-holder" > <div class = "wtcpl_category_nav" id= "wtcpl_tabs" > <?php $product_categories = unserialize(get_option( 'selected_categories' )); if (! empty ( $product_categories ) ){ $category_orders = get_option( 'category_order' ); if ( $category_orders == 'menu_order' ){ $args = array ( 'number' => '' , 'order' => 'asc' , 'orderby' => 'menu_order' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'exclude' => $product_categories , //'include' => $category_ids, ); } else if ( $category_orders == 'term_order' ){ $args = array ( 'number' => '' , 'order' => 'asc' , 'orderby' => 'term_order' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'exclude' => $product_categories , //'include' => $category_ids, ); } else { $args = array ( 'number' => '' , 'order' => get_option( 'category_order' ), 'orderby' => 'title' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'exclude' => $product_categories , //'include' => $category_ids, ); } } else { $category_orders = get_option( 'category_order' ); if ( $category_orders == 'menu_order' ){ $args = array ( 'number' => '' , 'order' => 'asc' , 'orderby' => 'menu_order' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'include' => '' ); } else if ( $category_orders == 'term_order' ){ $args = array ( 'number' => '' , 'order' => 'asc' , 'orderby' => 'term_order' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'include' => '' ); } else { $args = array ( 'number' => '' , 'order' => get_option( 'category_order' ), 'orderby' => 'title' , 'hide_empty' => $qc_woo_tabbed_show_empty_category , 'include' => '' ); } } // $product_categories = get_terms('product_cat', $args); $product_categories = get_terms( 'product_cat' , $args ); ?> <ul> <?php $i = 0; foreach ( $product_categories as $cat ) { $slug_url = (get_option( 'qcld_use_category_tab' ) == 'id' ) ? $cat ->term_id : $cat ->slug; ?> <li><a id= "<?php echo esc_attr($slug_url); ?>" class = "product-<?php echo esc_attr($slug_url); echo($i == 0 ? ' active' : ''); ?>" data-name= "<?php echo esc_attr($cat->name); ?>" href= "#" > <?php if (! empty (get_option( 'qc_woo_tabbed_enable_category_image' )) || ( isset( $cat_image_on_top ) && $cat_image_on_top == 'enable' ) ){ qcld_get_category_image( $cat ->term_id); } ?> <?php echo esc_attr( substr ( $cat ->name, 0, get_option( 'max_char_per_cat' ))); ?></a> </li> <?php $i ++; } wp_reset_query(); ?> </ul> <!-- <div class = "clear" ></div>--> </div> </div> <div class = "product_content" id= "wtcpl_tabs_container" > <?php $i = 0; foreach ( $product_categories as $cat ) { $slug_url = (get_option( 'qcld_use_category_tab' ) == 'id' ) ? $cat ->term_id : $cat ->slug; ?> <div class = "each_cat<?php echo($i == 0 ? ' active' : ''); ?>" id= "product-<?php echo esc_attr($slug_url); ?>" > <?php $args_query = array ( 'post_type' => 'product' , 'post_status' => 'publish' , 'tax_query' => array ( 'relation' => 'OR' , array ( 'taxonomy' => 'product_cat' , 'field' => 'term_id' , 'terms' => $cat ->term_id, 'operator' => 'IN' ), ) ); $product_querys = new WP_Query( $args_query ); $product_nums = $product_querys ->post_count; if ( $product_nums > 0){ echo do_shortcode( '[product_category category="' . esc_attr( $cat ->slug) . '" per_page=' . esc_attr( $product_number ) . ' columns=' . esc_attr( $column_number ) . ' orderby="' . esc_attr(get_option( 'qcld_orderby_product' )) . '" order="' . esc_attr(get_option( 'order_product_by' )) . '"]' ); } else { echo "<div class='wtcpl_category_empty_msg'> " . esc_html( get_option( 'qc_woo_tabbed_show_empty_category_msg' ) ) . " </div>" ; } ?> </div> <?php $i ++; } wp_reset_query(); ?> </div> </div> <?php return ob_get_clean(); // } } |
Code file location:
woo-tabbed-category-product-listing/woo-tabbed-category-product-listing/woo-tabbed-category-product-listing.php
Conclusion
Now that you’ve learned how to embed the Tabbed Category Product Listing for Woocommerce Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply