0

Before this I never get any problem using this code on my WordPress function, but by this month my error because of this code.Can someone detect the problem? You can try put this on your WordPress function.php . It's used to be count counter

<?php

function my_title_count(){ ?>
<script>jQuery(document).ready(function(){
jQuery("#titlediv .inside").after("<div style=\"position:absolute;top:40px;right:-5px;\"><span>Max 57 characters:</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');
?>

<?php function my_excerpt_count(){ ?>
<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:4px;right:25px;\"><span>Max 156 characters:</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');
?>

source: http://passwordincorrect.com/add-character-count-to-title-and-excerpt-in-wordpress-post-editor/

user3546314
  • 124
  • 1
  • 13

0 Answers0