Created
June 30, 2019 07:27
-
-
Save rajucs/88d734f40bb31cee4d80a1253a80d4c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 ); | |
function shorten_woo_product_title( $title, $id ) { | |
if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' ) { | |
return wp_trim_words( $title, 3, '...' ); // change last number to the number of words you want | |
} else { | |
return $title; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment