I have a function/php code which shows title excerpts but always shows ‘…’ even if the title doesnt exceed the length.

Does anyone know a way which the ‘…’ will only show if the title is too long?

Thanks

FUNCTION

// Title Excerpt//
function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title();
    if ( $length && is_numeric($length) ) {
        $title = substr( $title, 0, $length );
    }
    if ( strlen($title)> 0 ) {
        $title = apply_filters('the_titlesmall', $before . $title . $after, $before, $after);
        if ( $echo )
            echo $title;
        else
            return $title;
    }
}
//End Title Excerpt

PHP IN LOOP

<?php the_titlesmall('', '', true, '15') ?>

Read more here: How do I only show Ellipsis if wordpress title exceeds length


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: