Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #377738

    Hello,

    Is there a way to truncate the blog title for the enfold grid layout? Some of my titles are very long and look weird next to shorter titles in the grid format. I know how to do it for a regular theme, but it requires access to the title code in the template. I do not see the title code in the index template and I don’t want to edit the parent files.

    Thank you,
    Bjorn

    #377908

    Hi bjornwallman!

    Thank you for using Enfold.

    Add this on functions.php:

    function limit_words($string, $word_limit){
    	$words = explode(" ",$string);
    	return implode(" ",array_splice($words,0,$word_limit)) . '...';
    }

    Edit config-template-builder > postslider.php, find this code on line 372:

    $output .= !empty($title) ? "<h3 class='slide-entry-title entry-title' $markup><a href='{$link}' title='".esc_attr(strip_tags($title))."'>".$title."</a></h3>" : '';
    

    Replace it with:

    $blogtitle = limit_words($title,5);
                        $output .= !empty($title) ? "<h3 class='slide-entry-title entry-title' $markup><a href='{$link}' title='".esc_attr(strip_tags($blogtitle))."'>".$blogtitle."</a></h3>" : '';
    

    This will limit the title to 5 words. Adjust it on this line:

    $blogtitle = limit_words($title,5);
    

    Regards,
    Ismael

    #377937

    Is there no way to do this within the child theme and without having to edit the parent theme?

    #378335
    #378529

    Works perfectly. Thank you very much!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Truncate the blog post title’ is closed to new replies.