• Resolved Alkorr

    (@alkorr)


    Hi, is there a way to limit the number of characters of the secondary title?

    (I can’t check the full FAQ since the author’s website is under construction right now…)

    Thank you for you help! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author thaikolja

    (@thaikolja)

    I’m not sure if I understand you correctly. Could you explain it a bit further and give some example? That would help me a lot.

    Thread Starter Alkorr

    (@alkorr)

    Hi thaikolja, sure. Let’s say my secondary titles usually contain 60 to 80 characters, but to fit my homepage design, I need to show shortened secondary titles (only 30 characters), how can I do that? It is possible to do it for Post Titles (there are plenty of snippets and plugins) but I have no idea how to do it with your plugin.

    Hope it helps 🙂

    Plugin Author thaikolja

    (@thaikolja)

    A very primitive solution to limit the output would be this (placed into functions.php of your theme):

    /**
        * Limits the secondary title to a
        * maximum of 30 characters.
        *
        * @param $secondary_title
        *
        * @return string
        */
       function limit_secondary_title_characters($secondary_title) {
    
          return (string)substr($secondary_title, 0, 30);
       }
    
       add_filter("get_secondary_title", "limit_secondary_title_characters");

    Please note that this will affect all secondary titles on your website unless you add some filtering.

    Please report back.

    • This reply was modified 8 years, 11 months ago by thaikolja.
    • This reply was modified 8 years, 11 months ago by thaikolja.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Make Secondary Title Shorter’ is closed to new replies.