Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Character counter for WordPress editor
<?php
// handy if you write status posts and send them to Twitter
function akv3_editor_char_count() {
?>
<script type="text/javascript">
(function($) {
wpCharCount = function(txt) {
$('.char-count').html("" + txt.length);
};
$(document).ready(function() {
$('#wp-word-count').append('<br />Char count: <span class="char-count">0</span>');
}).bind( 'wpcountwords', function(e, txt) {
wpCharCount(txt);
});
$('#content').bind('keyup', function() {
wpCharCount($('#content').val());
});
}(jQuery));
</script>
<?php
}
add_action('dbx_post_sidebar', 'akv3_editor_char_count');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment