Zen Follower
- Join Date:
- Jul 2009
- Location:
- Texas
- Posts:
- 210
- Plugin Contributions:
- 0
Add simple count to meta title and meta descriptions
Google and other search engines like your titles and descriptions to be a certain length. I wrote this piece of code today to easily display a count of how many characters I had in my titles and descriptions.
File to modify is: /admin/includes/footer.php
</footer>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
function char_count(max, selector) {
var selector_name = selector.replace(/[^\w]/g,'');
var char1 = max - $(selector).val().length;
$( '<span class="count_' + selector_name + '">(' + char1 + '/' + max + ')</span>' ).insertAfter(selector);
$(selector).keyup(function () {
var char2 = max - $(selector).val().length;
$('.count_' + selector_name).text('(' + char2 + '/' + max + ')');
});
}
char_count(60,'input[name^=metatags_title]:text');
char_count(160,'textarea[name^=metatags_description]');
</script>
Hope it helps someone.
DentalPlanet Designed/Administrated by Falls Geek