mardi 30 août 2016

How to add a break if product title is less than a certain amount of charaters

I am trying to get more of a consistent grid layout on my shop loop.

The product title spans over 1 or 2 lines depending on the string length, therefore if the string length is below the amount which forces it to overlap to the next line I want to add a break '
' so that it doesn't affect the overall spacing of the shop loop page

This is what i have at the moment

<?php
    echo "test";
    $title = get_the_title();
    if (strlen($title) <29 )
    {
    echo '<br>';
    }
?>

I have tried putting it in content-product.php but its not working Is my code correct?

Any help would be greatly appreciated

Aucun commentaire:

Enregistrer un commentaire