When you want to keep your post titles as short as possible and you work with multiple authors, this might be a problem. Everyone would have to take care of their titles, count words or letters and it would probably be a hard time doing that every time when you write a new article. According to experts, an ideal length of any given title for a website article or post is under 60 characters long. This is to allow your title to be easily viewed in most search engines.  So, in this article, we will show you how to add character limit to post titles in WordPress.

How to add character limit to posts title in WordPress with a plugin

First thing you need to do is install and activate the Limit Post Titles plugin.  It’s a simple, yet effective means to show admins and authors alike how close they are coming to the maximum set length of a title. Upon activation, simply go to Settings » Limit Post Titles to configure the plugin settings.

You need to enter the character limit and select the post types where you want to enable this character limit. Next, click on the save settings button to store your settings.

How to add character limit to posts title in WordPress with a function

Another simple solution is to use a php function. Open functions.php in your theme and paste following code:

function sow_max_title_length( $title ) {
$max = 52;
if( strlen( $title ) > $max ) {
return substr( $title, 0, $max ). " …";
} else {
return $title;

Place the next function wherever you want in your theme. For example, if you want to show shortened titles on your homepage, you want to place this code into your Main Index Template (index.php).

add_filter( 'the_title', 'sow_max_title_length');

As you can see in the code, variable $max is used to limit the length of your post title. You are free to change it to any number you want – be aware that the optimal length of your title is between 50 and 60 characters.

We hope this article helped you add character limit to post titles in WordPress.