Answers for "$trim_length = $custom_field = 'field-name'"

0

$trim_length = $custom_field = 'field-name'

$trim_length = 100;  //desired length of text to display
$custom_field = 'my-custom-field-name';
$value = get_post_meta(get_the_ID(), $custom_field, true);
if ($value) {
 $trimmed_value= rtrim(substr($value,0,$trim_length));
 if (strlen($trimmed_value) >= $trim_length)
    $trimmed_value .= " ...";
 echo $trimmed_value;
}
Posted by: Guest on March-04-2021

Browse Popular Code Answers by Language