Support » Plugin: Livemesh Addons for Elementor Page Builder » post carousel – limit the words in post entry summary

  • Resolved farbfaeltigaa

    (@farbfaeltigaa)


    hi,
    how can i limit the words/characters in der post-entry-summary?
    ——————-
    thanks
    john

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author livemesh

    (@livemesh)

    This option is available only in the premium version of the plugin.

    With the free version, you can accomplish the same by overriding the WP hook/filter named ‘lae_posts_grid_entry_excerpt’.

    There are number of examples of how to use filters here – https://gist.github.com/live-mesh/90a79048686651fa0bfbf0eb40493611 and the above mentioned filter is available at includes/widgets/portfolio.php line number 929.

    hi,
    now i have limit the words in excerpt with:

    add_filter('lae_posts_carousel_entry_excerpt', 'mytheme_restrict_excerpt', 10, 1);
    
    function mytheme_restrict_excerpt($excerpt) {
    
        $excerpt = '<div class="entry-summary">';
    
        $length = 170; // ......

    How can i add a “read more button”? it didn’t work with (see link below) because of limit the excerpt, the button is affected.

    https://wordpress.org/support/topic/read-more-link-to-post-carousel/

    Plugin Author livemesh

    (@livemesh)

    You can just append the read more button to the excerpt like below –

    add_filter('lae_posts_carousel_entry_excerpt', 'mytheme_restrict_excerpt', 10, 1);
    function mytheme_restrict_excerpt($excerpt) {
        $excerpt = '<div class="entry-summary">';
        $length = 120; // number of characters without breaking the words
        $append = '...';
        $string = get_the_excerpt();
        $string = trim($string);
        if(strlen($string) > $length) {
            $string = wordwrap($string, $length);
            $string = explode("\n", $string, 2);
            $string = $string[0] . $append;
        }
        $excerpt .= $string;
        
        $read_more_text = __('Read More', 'livemesh-el-addons');
        $excerpt .= '<div class="lae-read-more">';
        $excerpt .= '<a class="lae-button" href="' . get_the_permalink($post_id) . '">' . $read_more_text . '</a>';
        $excerpt .= '</div><!-- .lae-read-more -->';
        
        $excerpt .= '</div><!-- .entry-summary -->';
        return $excerpt;
    }
    farbfaeltigaa

    (@farbfaeltigaa)

    Thank you, works fine.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.