Skip to content

Instantly share code, notes, and snippets.

@schemapress
Created July 14, 2018 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schemapress/5c78a89eaca39e261ff0db562c8f50c3 to your computer and use it in GitHub Desktop.
Save schemapress/5c78a89eaca39e261ff0db562c8f50c3 to your computer and use it in GitHub Desktop.
Truncating Headlines by words count in Schema Plugin https://schema.press/docs/truncating-headlines/
<?php //* do not include php tag
add_filter('schema_wp_filter_headline', 'truncating_headlines_words_567545256');
/**
* Schema Plugin: Truncating Headlines by words count
*
* @since 1.0
*/
function truncating_headlines_words_567545256( $headline ) {
$word_count = 6; // number of words
$short_headline = wp_trim_words( $headline, $word_count, '' );
return $short_headline;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment