woocommerce related product title length

Can’t believe there is no standard workaround to limit product title for the related product section. So far, I managed to limit product title for all other pages by using Woo Title Limit plugin.

By using this plugin, I can make the related product to limit its title by inserting limit to single product page, but then it will affect the single product title also. So, I think the best way is to add it manually for the related product.

I think this is the standardize code to limit product title character.

if ( strlen( $title ) > 60) { // Kicks in if the product title is longer than 60 characters
return substr( $title, 0, 60 ) . ‘…’; // Shortens it to 60 characters and adds ellipsis at the end
} else {
return $title; // If the title isn’t longer than 60 characters, it will be returned in its full length without the ellipsis
}

Now, the problem is where can I apply this code? I can’t just simply paste this code inside the related.php page right? Mine guiding me on what things I need to sort out first?

Read more here:: woocommerce related product title length

Leave a Reply

Your email address will not be published. Required fields are marked *