Forums

How can I shorten the_title? (2 posts)

  1. quemultimedia
    Member
    Posted 1 year ago #

    Greetings All,

    Step by step, I'm working on a custom theme for my wordpress install. Thus, I would like to shorten the output of the_title(); because the current output is 'breaking' my design layout.

    Is it possible to shorten the output to, for example, 75 characters?

    Cheers All

  2. threestyler
    Member
    Posted 1 year ago #

    This is one way of doing it:

    <?php if (strlen($post->post_title) > 75) {
    echo substr(the_title($before = ”, $after = ”, FALSE), 0, 75) . ‘…’; } else {
    the_title();
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic