How To Limit The Title Of WordPress Posts Articles


09.03.2011

How To Limit The Title Of WordPress Posts Articles

WordPress is CMS (Content Management System), which has a rich plugin architecture allowing its users to extend its functionality adding other feature besides the ones that come with the base install. WordPress is one of the most used application when in comes to blogs and web sites publishing.

This article is written to help WordPress users to manage it more easily, If you ever asked yourself you to limit the post titles, this is how you do it.

Copy and Paste this code in functions.php:

<?php function limit_title(How To Limit The Title Of WordPress Posts Articles, $n){
if ( strlen (How To Limit The Title Of WordPress Posts Articles) > $n )
{
echo substr(the_title($before = ”, $after = ”, FALSE), 0, $n) . ‘…’;
}
else { the_title(); }
}
?>

Next, go to your WordPress theme templates and introduce this function:

<?php limit_title($post->post_title, 30); ?>

Note that the number in the gap (30 her) represents the number of the symbols you want to limit, and you should use the function in the post loop.

WordPress


Tags: wordpress, function, limit, users, post, number, title, strlen, limit_titletitle, echo, substrthe_titlebefore, false, after, yourself, paste, copy, ‘…’, code, functionsphp, titles, next, represents, note, symbols, want, loop, should, post_title, limit_titlepost, asked