coningham
2/26/2015 - 1:05 PM

Character count for title and excerpt (usei no Jornal de Valinhos)

Character count for title and excerpt (usei no Jornal de Valinhos)

function my_title_count(){ ?>
<script>jQuery(document).ready(function(){
jQuery("#titlediv .inside").after("<div style=\"position:absolute;top:40px;right:-5px;\"><span>Max 40 caracteres:</span> <input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"title_counter\" readonly=\"\" style=\"background:none;border:none;box-shadow:none;font-weight:bold; text-align:right;\"></div>");
jQuery("#title_counter").val(jQuery("#title").val().length);
jQuery("#title").keyup( function() {
jQuery("#title_counter").val(jQuery("#title").val().length);
});
});
</script>
<? }
add_action( 'admin_head-post.php', 'my_title_count');
add_action( 'admin_head-post-new.php', 'my_title_count');
 
function my_excerpt_count(){ ?>
<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:4px;right:25px;\"><span>Max 140 caracteres:</span> <input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\" style=\"background:none;border:none;box-shadow:none;font-weight:bold; text-align:right;\"></div>");
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length);
jQuery("#excerpt").keyup( function() {
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length);
});
});
</script>
<? }
add_action( 'admin_head-post.php', 'my_excerpt_count');
add_action( 'admin_head-post-new.php', 'my_excerpt_count');