6h8j5 6h8j5 - 3 months ago 50
PHP Question

mb_strimwidth on implode list

I have the following code which gets a list of terms and seperates them using a slash, e.g.


I want to limit that text to 28 characters, I have attempted to use

but I get a Call to undefined function where the function name is the output of

$term_list = wp_get_post_terms( get_the_ID(), 'type', array( "fields" => "names" ) );
$type_seperated = implode('/', $term_list);
if ( ! empty( $term_list ) ) : ?>
<?php echo mb_strimwidth($type_seperated(), 0, 28, '...'); ?>
<?php else : ?>
<?php _e( 'N/A', 'text-domain' ); ?>
<?php endif; ?>

Is this not possible? Does the $type_seperated output need to be a string? How do I do this?


Confirm that $type_seperated() function exists which return strings. If you mistakenly used parenthesis () then remove parenthesis which means it should be like <?php echo mb_strimwidth($type_seperated, 0, 28, '...'); ?>