How to limit letter of WordPress post title

How to limit letter of WordPress post title? Just replace this code

<?php the_title(); ?>

with the following code.

<?php if (strlen($post->post_title) > 35) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 35) . '...'; } else {
the_title();
} ?>

This code is very helpful to limit WordPress post title.


Leave a Reply