// Add Character Counter to the Excerpt Meta Box function excerpt_count_js(){ if ('page' != get_post_type()) { ?> <script> (function($){ $(document).ready(function(){ if ( $('#postexcerpt').length ) { var maxChar = 128; $excerpt = $('#excerpt'); $("#postexcerpt .handlediv").after( '<div style="position:absolute;top:5px;right:80px;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). (' + maxChar + ' Characters MAX)</small>' + '</div>' ); $excerptCounter = $("#excerpt_counter"); $excerptCounter.val( $excerpt.val().length ); $excerpt.keyup( function() { $excerptCounter.val( $excerpt.val().length ); var exColor = ( ( $excerptCounter.val() > maxChar ) ? 'red' : 'green' ); $excerptCounter.css( 'color', exColor ); }); } }); })(jQuery); </script> <?php } } add_action( 'admin_head-post.php', 'excerpt_count_js'); add_action( 'admin_head-post-new.php', 'excerpt_count_js');