Hello Support,
How can I limit the Titles to be only in one line instead of 2 or more.
Hope to hear from anyone soon.
Thanks,
MP
Hey Marcelo!
Change your layout from 1/3 to 1/2 columns to make more space for the titles and/or reduce its font size:
strong.news-headline {
font-size: 11px;
line-height: 13px;
}
Cheers!
Josue
Hello Josue,
Actually is there a way to have a character limit on the title to eg: 33 characters.
Once the user clicks and takes them to the full post then it will show the full title.
Thanks,
MP
Hi!
Yes, there is a way using jQuery, please note that this is normally out of the scope, try adding this to theme / child theme functions.php:
function add_custom_script(){
?>
<script>
(function($){
$(window).load(function() {
$('.news-link').each(function(){
var $this = $(this);
var title = $this.attr('title');
var headline = $this.children('.news-headline');
var maxWords = 33;
if (title.length > maxWords){
headline.text($.trim(title).substring(0, maxWords).split(" ").slice(0, -1).join(" ") + "...");
}
});
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');
Adjust as needed.
Regards,
Josue
Thank you so much Josue.
I have added the code in the child theme.
FYI: You guys should have have another package of support for out of scope requests :)
Either way thanks for the amazing support.
MP
You are welcome, glad to help :)
Regards,
Josue
Thanks for your help.