Reputation: 23
<h2 class="entry-title" itemprop="headline">
<a href="http://alzheimerscare.in/lorem-ipsum-is-simply-dummy-text-of-the-printing-and-typesetting-industry-lorem-ipsum-has-been-the-industrys/" title="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s" rel="bookmark">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s</a>
</h2>
I want to trim wordpress blog post title to minimum 15 characters, there are many posts are there in the page and i want to trim the title using jquery or javascript to minimum 15 characters of each post. thank you.
Upvotes: 0
Views: 564
Reputation: 5310
This should do the trick. It finds every title on the page, trims it to fifteen characters and adds "..." - Unless you are then doing some kind of "show/hide" effect or something else, this would likely be better accomplished in php ;)
$(".entry-title a").each (function () {
if ($(this).text().length > 15)
$(this).text($(this).text().substring(0,15) + '...');
});
Upvotes: 2