Code to Limit the Character On Post Title In WordPress Blog

Posted by


In many cases wordpress user wants to display certain limit on post title without affecting the permalink settings. For that use this code:

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

This code will display first 40 characters of the post title. You can set it as per your requirement.

That’s it!


Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.