Easily Add Character Counter to the WordPress Excerpt Box

Many WordPress theme uses excerpt meta box data to show up in home page or any other category page. If you are not a WP developer or a regular user and using a theme where it is showing data from excerpt and looks like a mess then you must add character counter to excerpt. You just nee to add a simple code to your theme function. Let’s see how you can easily add character counter to the WordPress excerpt box.

First of all if you can’t see the excerpt meta box in your post then select it first:


Then add the following code in your theme function:

[html]function excerpt_count_js(){
echo ‘<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:0px;right:5px;color:#666;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\" style=\"background:#fff;\"> <small>character(s).</small></div>");
jQuery("#excerpt").keyup( function() {
add_action( ‘admin_head-post.php’, ‘excerpt_count_js’);
add_action( ‘admin_head-post-new.php’, ‘excerpt_count_js’);[/html]

Author: mytutorialguru

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *