I’m using custom fields to pull a secondary description. I’d like to use the built in WordPress truncate but can’t seem to figure it out.
$desc = get_post_meta($post->ID, "youtube-desc", true);
echo '<p>' . $desc . '</p>';
Any help would be appreciated.
See the discussion for Taxonomy Short Description for a better way to shorten a string. Iâm not aware of a WP function that is getting truncation right.
Here is my code based on the linked discussion:
Test
Add the function to your
functions.php
and change your code to:You can also use it shorten a title: