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

Avani Gregg Net Worth: How Rich is the Tik Tok Superstar?

Avani Gregg Net Worth: How Rich is the Tik Tok Superstar?

Avani Gregg is an American social media personality who is best known for being a star in the lip-sync and dance platform called TikTok. Here, she has managed to gain an impressive following of over 8.2 million followers along with 420 million likes in her videos. As of 2020, Avani Gregg net worth is estimated […]

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp Net Worth: How Rich is the Radio host Actually?

Roman Kemp is an English radio host and presenter. He presents for the national radio network Capital FM and is part of the nineteenth series of I’m a Celebrity…Get Me Out of Here!. As of 2019, Roman Kemp net worth is estimated to be £2 million. Kemp was born on 28 January 1993, in Los […]

Korey Wise Net Worth: How Rich is Central Park Five Member?

Korey Wise Net Worth: How Rich is Central Park Five Member?

Korey Wise is one of the members of the Central Park Five. Wise was only 16 years old when he was arrested in 1989 in connection to the rape of Trisha Meili. Korey Wise net worth is estimated to be $12 million. Korey Wise along with Yusef Salaam, Antron McCray, Raymond Santana, and Kevin Richardson […]

%d bloggers like this: