Ajouter un compteur de caractère a la fonction extrait

Pour afficher un compteur de caractère à la fonction extrait, ajouter le code ci-dessous dans le fichier function.php de votre Thème WordPress :

function excerpt_counter_js(){
      echo '<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:5px;right:25px;color:#666;\"><small>Longueur de l\'extrait: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\" style=\"background:#fff;\"> <small>caractère (s).</small></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', 'excerpt_counter_js');
add_action( 'admin_head-post-new.php', 'excerpt_counter_js');
0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest

0 Commentaires
Commentaires en ligne
Afficher tous les commentaires