• Could we please have a character count added to the category description field!

    After all this is the META tag description and has a limit of 150-160 characters. Right now I have to write them in my word processor, perform a character count there, then edit and count again until correct, and finally copy and past into WordPress! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is old topic, but I find a simple solution. Add this to your functions.php (use child theme):

    // Counting characters in Category description
    function category_count_js(){
    	if ('page' != get_post_type()) {
    		echo '
    		<script>jQuery(document).ready(function(){
    			jQuery("#description").after("<div style=\"position:relative;float:right;color:#666;\">Description length: <span id=\"excerpt_counter\"></span> / 280 character(s).</div>");
    			jQuery("span#excerpt_counter").text(jQuery("#description").val().length);
    			jQuery("#description").keyup( function() {
    				if(jQuery(this).val().length > 280){
    					jQuery(this).val(jQuery(this).val().substr(0, 280));
    				}
    			jQuery("span#excerpt_counter").text(jQuery("#description").val().length);
    			});
    		});</script>';
    	}
    }
    add_action( 'admin_head-edit-tags.php', 'category_count_js');

    This counts until 280 characters – you can change 280 in code to your liking.

    It cuts the text at 280 characters – you change that by removing

    if(jQuery(this).val().length > 280){
    	jQuery(this).val(jQuery(this).val().substr(0, 280));
    }

    Thread Starter webbeetle

    (@webbeetle)

    Cheers!

    (I would love to write my own php – but no time to learn…)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘a character count for category description!’ is closed to new replies.