Connect with us

Tips & Tricks

Limit the characters that display on the_title

Ever wanted to display the title of a post somewhere but limit the amount of characters that are shown? For instance, this post has a very long title, and if I were to use <?php echo the_title() ?> it would show as follows: Limit the characters that display on the_title.

That may not fit well on one line in lets say a widget or small width div. So here is a neat trick you can use:

<?php $title = the_title('','',FALSE); echo substr($title, 0, 11); ?>

Pretty simple huh, just note the bold numbers, in this case 11 character would output like this: Limit the c.

Thanks to Tattershall Way for this snippet.

3 Comments

3 Comments

  1. Pingback: WordPress links week 4 - 2009 | WPStart.org - WordPress themes, plugins and news

  2. Daniel

    May 23, 2009 at 7:04 am

    Cheers. Very useful. 🙂

    I don’t suppose could help me with adding a little extra to this. I want to put “…” at the end if the amount of chars in the title exceeds the cut off point.

    • Austin

      May 25, 2009 at 2:45 pm

      Hmm, not really sure how to print that if, and only if characters are less than whats printed. May want to chack out pnp.net

You must be logged in to post a comment Login

Random Search Terms

Title

Top Articles

powered by WassUp

Recent Posts: Fully Net Worth . com

Emma Barton Net Worth: How Rich is the English Actress Actually?

Emma Barton Net Worth: How Rich is the English Actress Actually?

Emma Louise Barton is an English actress who is best known for playing the role of the character named Honey Mitchell in EastEnders. She is currently part of the seventeenth edition of the popular dance show called Strictly Come Dancing. As of 2019, Emma Barton net worth is estimated to be $2 million. Barton was […]

Alison Victoria Net Worth: How Rich is Alison Victoria Actually?

Alison Victoria Net Worth: How Rich is Alison Victoria Actually?

Alison Victoria is an interior designer and a television personality who is best known for being the host of the HGTV show called “Windy City Rehab” where she and lead contractor Donovan Eckhardt renovate different houses in Chicago and flip them. The series is set to release it’s season 2 in 2020. As of 2019, […]

Joey Buttafuoco Net Worth: How Rich is Buttafuoco Actually?

Joey Buttafuoco Net Worth: How Rich is Buttafuoco Actually?

Joey Buttafuoco is an American body shop owner who had a sexual relationship with minor Amy Fisher, who subsequently shot his wife Mary Buttafuoco in the face. As of 2019, Joey Buttafuoco net worth is estimated to be $800,000. Joey was born on March 11, 1956, in Massapequa, New York. He graduated from Massapequa High […]

%d bloggers like this: