Reputation: 151
on a wordpress theme i am trying to make i have some what narrow spaces for the post titles. Normally it is ok when the words aren't too big (because a word can always go to the next line), but when there is a very long word (like "ANTIDISESTABLISHMENTARIANISM") then it is a problem.
I thought a solution could be to check with jQuery if on the title there is any word with more than x characters. i wanted to start be trying the total amount of characters in the title (vs. looking for long single words in side the title).
My code looks like this:
$(function(){
var $title = $(".entry-title a").text();
var $titlesize = $title.lenght();
if ($titlesize > 10){
$(title).css("color","red");
}
});
(on this example i try to change the text color, so it is easy to see if it working or not... ;) ).
Any ideas on i could solve this? Would something like this affect ALL of the post titles or just the one which is too big?
Upvotes: 0
Views: 1702
Reputation: 208032
Why don't you just use CSS to handle this? Use the word-break
property.
Ex: word-break: break-all;
Upvotes: 2