• Hi there!

    First of all, thank you for this great plugin. I just started translating my site to a second language and the plugin’s response has been excellent so far (like in any other context). Really happy with it! Thank you ??

    Ok, here is my issue: I’d like to be able to limit the post title length, preferably to a certain amount of characters… or to a certain amount of lines.

    I’ve tried the following methods, but none of them offer the desired outcome or are cross-browser effective:
    1. Text truncation with css, using text-overflow: ellipsis. Like this:

    white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    Problem: it only works with one line of text. Too limiting.

    2. -Webkit-line-clamp property

    overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical; 

    This would be perfect because it lets me decide the number of lines to display, but only works in webkit browsers…

    I know that it’s not possible to specify the character length via css, but maybe there’s a way to do it editing a plugin file. In any case, I would really appreciate some help in this regard.

    Thank you in advance!!! ??

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • plugins/recent-posts-widget-extended/includes/functions.php and line 170:

    $html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a></h3>';

    replace (words, max 5)

    $html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . wp_trim_words( get_the_title(), 5 ) . '</a></h3>';
    

    or (characters, max 20)

    $html .= '<h3 class="rpwe-title"><a href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'recent-posts-widget-extended' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . mb_strimwidth( get_the_title(), 0, 20, '...' ) . '</a></h3>';

    Thread Starter piterkaillada

    (@thebea58)

    Thank you very much, that was a great solution. Excellent support one more time!!!

    I hope you don’t mind me asking this: is there any way to limit the post title to a certain amount of lines (instead of words or characters) that’s cross browser?

    Thank you again!

    I have no idea

    Thread Starter piterkaillada

    (@thebea58)

    OK. Thanks anyway

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shorten post title’ is closed to new replies.