Skip to content

Instantly share code, notes, and snippets.

@schemapress
Created July 14, 2018 11:34
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/a355ad4a0b66f8a28ecb453cf4d0e1cb to your computer and use it in GitHub Desktop.
Save schemapress/a355ad4a0b66f8a28ecb453cf4d0e1cb to your computer and use it in GitHub Desktop.
Truncating Headlines by characters count in Schema Plugin https://schema.press/docs/truncating-headlines/
<?php //* do not include php tag
add_filter('schema_wp_filter_headline', 'truncating_headlines_chars_567545256');
/**
* Schema Plugin: Truncating Headlines by characters count
*
* @since 1.0
*/
function truncating_headlines_chars_567545256( $headline ) {
$char_count = 110; // number of characters
$short_headline = mb_strimwidth( $headline , 0, $char_count, '');
return $short_headline;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment