function trim_words_shortcode( $atts, $content = '' ) {
extract( shortcode_atts( array(
'length' => '40',
'after_url' => '',
'after_text' => 'Read More'
), $atts ) );
$link = "<a href='{$after_url}'>{$after_text}</a>";
$append = " ...{$link}";
return wp_trim_words( $content, $length, $append );
}
add_shortcode('trim_words', 'trim_words_shortcode');
/*
* Usage: [trim_words length="36" after_url="" after_text=""][types field="title"][/types][/trim_words]
* Output: It will take the data stored in whatever types field you are wrapping the shortcode around, truncate it down to X words you define, and use the URL and TEXT you pass in to append to the end after the hellips (...)
*/