I'm trying to add some custom HTML to specific WooCommerce products for my client. I successfully learned to add this custom HTML to all product pages at once (more specifically to their descriptions, overriding short-description.php) but I only need products A, B and C to contain this HTML bit and the rest to stay with the default content. A, B and C are in the same product category. How would you narrow the products, via category or product by product, that will contain this HTML, please?


check the documentation to add something for a particular posts/pages/category http://codex.wordpress.org/Conditional_Tags

  • It worked by finding which post # is the product page for A, B and C and then using is_single() with the custom HTML for each. Thanks a lot. – Luiz Cruz Jul 22 '16 at 15:44

You can check woocommerce related conditional tag here -


You can try below code. In this code add_action execute only when product have category like men or women.

function wp_extracode_for_products()
  echo'your code'; 

add_action( 'wp', 'remove_product_content' );

function remove_product_content() {

  if ( is_product() && (has_term( 'men', 'product_cat' )|| has_term( 'women', 'product_cat' ) )) {

   add_action('woocommerce_single_product_summary', 'wp_extracode_for_products', 60);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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