Hi there,
To remove the product meta (SKU, categories, tags) from the single product page in WooCommerce, you need to unhook the woocommerce_template_single_meta
action from the woocommerce_single_product_summary
hook. The code you provided seems correct for this purpose, but it’s important to note that the quotes used in your code are not standard single quotes—they are typographic quotes, which can cause issues in PHP. Make sure to use standard single quotes or double quotes in your PHP code.
Here’s the corrected code:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
To ensure that this code works regardless of the theme, you should place it in your child theme’s functions.php
file, or in a custom plugin. Additionally, it’s possible that some themes or plugins might alter the default WooCommerce hooks or priorities. In such cases, you may need to adjust the priority of your remove_action
calls to ensure they execute after the theme or plugin has added its actions.
If the code still doesn’t work, you may need to increase the priority of the remove_action
call to ensure it runs after the actions have been added by the theme or plugin. For example:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 100 );
If you’re unsure about the correct priority to use, you can try using a very high number to ensure your remove_action
is called last.
Finally, if your theme or a plugin is using a different hook or function to display the product meta, you will need to investigate the theme or plugin files to find the correct hook and callback function name to remove.
As a last resort, if you’re unable to find the correct hook or if the theme is hardcoding the meta without using actions, you can override the woocommerce_template_single_meta
function in your child theme. You would copy the original function from woocommerce/templates/single-product/meta.php
to your child theme’s WooCommerce folder (typically your-child-theme/woocommerce/single-product/meta.php
) and then make your changes there. However, this should be a last resort as it can make future updates more difficult.