I am using this code here:
<?php
$trim_length = 25; //desired length of text to display
$custom_field = 'my-custom-field-name';
$value = get_post_meta($post->ID, $custom_field, true);
if ($value) {
echo rtrim(substr($value,0,$trim_length));
}
?>
It works - but I would like to have a "(...)" at the end of the trimmed text. And only if the value really was trimmed.
I used if ($value) {
echo rtrim(substr($value,0,$trim_length)) . '(...)';
}
?>
But this makes the "(...)" at the end of every text from custom field..
Thank you!
AD
strlen()
orsubstr()
.