Support » Fixing WordPress » Shorten the_title()

  • I am trying this on the_title():

    <?php substr(the_title('', '', FALSE), 0, 22); ?>..

    However it won’t work.. It doesn’t show the title at all, but when I do this:

    <?php substr(the_title(), 0, 22); ?>..

    It shows the title, but doesn’t shorten it. I need to show only the first 22 characters.. How do I go about doing that?..

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    you need to echo the substr:

    <?php echo substr(the_title('', '', FALSE), 0, 22); ?>

    Ah wow.. thanks. I should have caught that >.<

    Do you have any idea on how to do that with the_content as well? I know it accepts two parameters. Right now I have ”, FALSE and it doesn’t strip them and I am echoing it out.

    Figured it out.

    function custom_excerpt_length($length) {
    	return 30;
    add_filter('excerpt_length', 'custom_excerpt_length', 999);
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shorten the_title()’ is closed to new replies.