On this page, you’ll find a few common issues for why WooCommerce shortcodes might not work as expected.
Shortcodes Cannot be Embedded between <pre> tags
If you correctly pasted your shortcodes and the display looks incorrect, make sure you did not embed the shortcode between <pre> tags. This is a common issue. To remove these tags, edit the page, and click the Text tab:
![Remove Pre Tags from Shortcode](https://woocommerce.com/wp-content/uploads/2012/01/WooCommerce-Shortcode-Pre-Tags.png?strip=all&w=704)
Another common problem is that straight quotation marks ("
) are displayed as curly quotation marks (“
). For the shortcodes to work correctly, you need straight quotation marks.
Variation Product SKU Not Shown
↑ Back to topIn regards to the use of SKU shortcode like [products skus="sku-name"]
, the variation product SKU isn’t intended to be displayed by itself, as opposed to the parent variable product SKU. Therefore, if you use an SKU from Product data > Variable product > Variations > Variation name > SKU, it does not display.
However, if we use an SKU from the parent variable product: Product data > Variable product > Inventory > SKU, it displays.
![](https://woocommerce.com/wp-content/uploads/2021/05/sku-variable-parent1.png?w=950)
Code Snippets
↑ Back to topNote: We are unable to provide support for customizations under our Support Policy. If you need to customize a snippet, or extend its functionality, seek assistance from a qualified WordPress/WooCommerce Developer. We highly recommend Codeable, or a Certified WooExpert.
Top-level Product Category List
↑ Back to topThe Product Categories List block can, as the name suggests, display a list of product categories. However, it doesn’t currently (April 2023) have the option to display only top-level categories and will display all categories, top-level and sub-categories alike.
This snippet adds a new shortcode [top_level_product_categories_list]
that outputs a bulleted list of top-level product categories only. Add it to a child theme’s functions.php file or via a code snippets plugin.
wc-shortcode-top-level-product-category-list.php content:
<?php
/*
* The shortcode is [top_level_product_categories_list]
*/
add_shortcode('top_level_product_categories_list', 'wc_shortcode_top_level_product_categories_list');
function wc_shortcode_top_level_product_categories_list() {
ob_start();
$args = array(
'taxonomy' => 'product_cat',
'parent' => 0
);
$product_categories = get_categories($args);
echo '<ul>';
foreach ($product_categories as $category) {
echo '<li><a href="' . get_term_link($category->slug, 'product_cat') . '">' . $category->name . '</a></li>';
}
echo '</ul>';
return ob_get_clean();
}
Questions and Support
↑ Back to topDo you still have questions and need assistance?
This documentation is about the free, core WooCommerce plugin for which support is provided in our community forums on WordPress.org. Searching there you’ll often find that your question has been asked and answered before.
If you haven’t created a WordPress.org account to use the forums, here’s how.
- If you’re looking to extend the core functionality shown here, we recommend reviewing available extensions in the WooCommerce Marketplace.
- Need ongoing advanced support, or a customization built for WooCommerce? Hire a WooExpert agency.
- Are you a developer building your own WooCommerce integration or extension? Check our Developer Resources.
If you weren’t able to find the information you need, please use the feedback thumbs below to let us know! 🙏