Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #290896

    Hi,

    there are lots of post showing how to get rid of date and featured image in the latest news widget, and cut the length of the excerpt. But how to shorten the length of the title? An ideal solution would be to cut it off at xx characters and add “…” at the end. But just cutting off would do as well.

    Best regards,
    Holger

    #290959

    Hey Holger!

    You need to change the php code in:

    enfold->framework->php->class-framework-widgets.php

    At line 519 you find:

    
    echo "<a class='news-link' title='".get_the_title()."' href='".get_permalink()."'>";
    

    Replace this with:

    
    $title = get_the_title();
    if(strlen($title) > 30)
    {
    $title = substr($title, 0, 27).'...';
    }
    echo "<a class='news-link' title='".$title."' href='".get_permalink()."'>";
    

    Best regards,
    Günter

    #290968

    Hi Günter,

    doesn’t seem to work. Probably my fault – I looked into the page source and realized, that the title got indeed truncated. What I meant is the headline – didn’t know that this is what is displayed. Here’s a link to see what I mean: http://infotropic.ru/?page_id=3288

    Best regards,
    Holger

    #291007

    Hey!

    You just have to go down the code and replace
    get_the_title()

    with

    $title

    in lines

    
    528 echo "<strong class='news-headline'>".get_the_title();
    545 echo "<strong class='news-headline'>".get_the_title()."</strong>";
    

    Regards,
    Günter

    #291039

    Günter, now it works perfect. Thanks a lot. Problem solved.

    Best regards,
    Holger

    #291046

    Hi!

    Glad we could help you. Enjoy the theme.

    Regards,
    Günter

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Latest news widget – shorten title length’ is closed to new replies.