Guest User

Untitled

a guest
Jun 15th, 2020
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Add custom badge to WooCommerce products in a specific category.
  3.  */
  4. function wpsimpel_add_category_product_badge() {
  5.  
  6.     if( has_term( 'posters', 'product_cat' ) {
  7.         echo '<span class="product-badge custom-badge">' . esc_html_e( 'New arrival', 'your-text-domain' ) . '</span>';
  8.     }
  9. }
  10. add_action( 'woocommerce_before_shop_loop_item_title', 'wpsimpel_add_category_product_badge' );
  11. add_action( 'woocommerce_before_single_product_summary', 'wpsimpel_add_category_product_badge' );
RAW Paste Data