Skip to content

Instantly share code, notes, and snippets.

@ovizii
Created April 12, 2014 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovizii/10559062 to your computer and use it in GitHub Desktop.
Save ovizii/10559062 to your computer and use it in GitHub Desktop.
Character count for content/excerpt
/* letter counter */
add_action( 'admin_head-post.php', 'letter_count_js'));
add_action( 'admin_head-post-new.php', 'letter_count_js' ));
public function letter_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<input type=\'text\' value=\'0\' maxlength=\'3\' size=\'3\' id=\'excerpt_counter\' readonly=\'\' style=\'background:#fff; position:absolute;top:0.2em;right:2em; color:#666;\'>"); jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); jQuery("#excerpt").keyup( function() {jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); }); jQuery("#wp-word-count").after("<td id=\'wp-character-count\'>Character count: <span class=\'character-count\'>0</span></td>"); jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); jQuery("#wp-content-wrap .wp-editor-area").keyup( function() {jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); }); });</script>'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment