Add character count to title and excerpt in WordPress post editor

If you want to have control over how many character has the title and excerpt of your new blog, you can add this information without any plugin.

This is helpful if you want to have a better control over how the post will be displayed on Google search engine result pages.

For both title and excerpt, character limits for Google SERP will be displayed as well. It will look like in the screenshot below:

Add character count to title and excerpt in WordPress post editor

Open functions.php file in your theme’s directory and paste at the end the code from below:

jQuery("#titlediv .inside").after("
Max 70 characters:
"); jQuery("#title_counter").val(jQuery("#title").val().length); jQuery("#title").keyup( function() { jQuery("#title_counter").val(jQuery("#title").val().length); }); }); jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("
Max 156 characters:
"); jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); jQuery("#excerpt").keyup( function() { jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); }); });

Obviously, there are plugins that simulate Google SERP view, naming only WordPress SEO by Yoast, but if you don’t use these plugins, with this piece of code, you are not completely blind.

More WordPress tips to check out:

[pi-archive number=5 tag=”wordpress”]

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: