Hello everyone!
Sering kita melihat nama produk katalog di WooCommerce tuh otomatis ganti baris ke bawah jika nama produknya panjang. Nah, ini dia tips-nya!
Dukung EstehC.
Copy-paste code di bawah dan buat file php dengan snippets.
Code PHP
function short_woocommerce_product_titles_chars( $title, $id ) {
if ( ( is_front_page() || is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === 'product' ) {
// Kicks in if the product title is longer than 16 characters
if ( strlen( $title ) > 16) {
// Shortens it to 16 characters and adds ellipsis at the end
return substr( $title, 0, 16 ) . '...';
}
}
return $title;
}
add_filter( 'the_title', 'short_woocommerce_product_titles_chars', 16, 2 );