This topic has 6 replies, 3 voices, and was last updated 6 years ago ago by Olga Barlow
Hi Guys,
I have this set up in the child theme but I cannot limit the Brand Description on the Single Product page to 40 charachters, this is what I need to alter:
<?php echo $brand->description;?>
It needs to be changed to something like this:
<?php echo wp_trim_words( $brand->description(), 40, '...' ); ?>
But what’s the correct php for this, any help would be greatly appriciated.
David
Hello,
Please try this code:
<?php if (strlen($brand->description()) > 40) { echo substr($brand->description(),0,40).'...';} else { echo $brand->description(); } ?>
Regards
Rose, your a star, you’ve gone one step further and by adding the condition.
There was an error in the code so I’ve changed it to:
<?php if (strlen($brand->description) > 145) { echo
substr($brand->description,0,145).'...';} else { echo $brand->description;
} ?>
I’ve taken out the () after description and it works brilliantly.
Thanks again.
David
You’re welcome!
Regards
this stopped working after the update to xstore5, I’ve changed it to:
<?php if (strlen($brand->description) > 145) { echo wp_specialchars_decode( substr($brand->description,0,245)).'...';} else { echo $brand->description; } ?>
Hello,
Ok, so does it work for you or you need any help from our side?
Regards
You must be logged in to reply to this topic.Log in/Sign up