How can I limit the text to say 100 characters from the get_post_meta tag?
I need to grab the text in this style:
<?php echo get_post_meta($relationship->ID, 'company_description', true ); ?>
This is how I would normally limit the text but I don’t know how to combine it with the syntax above:
<?php echo substr($fields->company_description,0,100) . "..."; ?>
The most readable way:
Then of course, you could also nest the function calls, which probably sucks in terms of readability:
By the way: If
company_descriptionmight contain raw HTML, you’ll probably want to runstrip_tags()over it before getting a substring – not stripping HTML would get you in trouble in the long run otherwise.