0

I wanna remove product meta(sku, category) from single product page. I tried different codes but nothing work. I am providing a 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 );

This code just working for NEVE theme but not for other theme , can you help me to find a way for removing product categories using PHP(not css).

2
  • Give a try to by using priority -99 in priority paramerter. Mar 1 at 5:24
  • 1
    Don't use curly quotes, they are invalid in PHP. Use ' instead.
    – fuxia
    Mar 1 at 12:11

1 Answer 1

1

If the code you provided is not working for other themes, it's possible that the hooks or actions used by those themes are different. To remove product categories from the single product page using PHP, you can try the following code:

function remove_product_meta() { remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); }

add_action( 'init', 'remove_product_meta' );

This code attempts to remove product metadata (which includes categories) on a single product page. The init action is used to ensure that the function is added early enough in the WordPress loading process.

If this still doesn't work, it is recommended to check the documentation of the theme you are using to find the correct action hook to remove the product meta. Themes can have different structures and it is important to find the right hooks to modify certain parts of the page. You should refer to the theme's documentation or contact the theme's support for assistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.