Support » Plugin: Schema » Truncate headlines to 110 chars

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hesham Zebida


    You can use something like:

    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;

    More details on implementing the code can be found in the documentation page.


    Sorry, but this shouldn’t even be something users need to set. The spec says 110 chars max – why would the plugin not adhere to this limitation? It should be in its core code.

    “The headline of the article. Headlines should not exceed 110 characters.”

    Plugin Author Hesham Zebida


    The main reason not to add this to the core would be the need of a new setting in the plugin settings page, which is something I try to avoid. This plugin should be light as possible not to have bad impact of heavy content sites.

    So, it would make more sense if users who wants special functionality to add it in Theme’s functions.php, or done by another plugin (extension for example).

    Why is there a need for a setting? This should be the default because otherwise you’re not adhering to the schema spec.

    Plugin Author Hesham Zebida


    There are more than one reason to add a setting for that:

    • Not all sites have same headlines length or set of words. So, the length of 110 chars not going to work for everyone. (for example: some headlines will require a limit less then 110 chars in some cases).
    • If we limit by words, then we will have a broken sentence.
    • If we limit by characters count, we will have a broken word.
    • Not every one will accept to have a broken sentence, or a word at the end of their headline.

    I’ve tested this with different types/lenths of headlines and got different results. You will get at least a broken sentence.

    That’s why I still think that a settings is needed to allow users to set a specific length and try to avoid all the points mentioned above!

    Also, not sure if adding ‘…’ at the end is a good idea! (your thoughts?)

    I am glad to add a new feature to the core if I can find a good way to do it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.