Author box (on posts) : limit the number of lines / or words / or caracters

Posted in: Newspaper
Post count: 25

Hello,

I need the description text of the author box (on the post page) to display fewer characters than what the description contains (and which will be displayed entirely on an author’s page, which groups his posts).

How to do it please? CSS? PHP?

Thank you
cordially

Post count: 22421

Hello,

You can add this code in your functions.php

function author_excerpt (){
$word_limit = 20; // Limit the number of words
$more_txt = 'read more about:'; // The read more text
$txt_end = '...'; // Display text end
$authorName = get_the_author();
$authorUrl = get_author_posts_url( get_the_author_meta('ID'));
$authorDescriptionShort = wp_trim_words(strip_tags(get_the_author_meta('description')), $word_limit, $txt_end.'<br /> '.$more_txt.' '.$authorName.'');
return $authorDescriptionShort;
}

and then modify the code in td_module_single_base:
https://www.screencast.com/t/SY6pVugA0 to https://www.screencast.com/t/S17suezq

Thanks.

Post count: 22421

Hello,

You can add this code in your functions.php

function author_excerpt (){
$word_limit = 20; // Limit the number of words
$more_txt = 'read more about:'; // The read more text
$txt_end = '...'; // Display text end
$authorName = get_the_author();
$authorUrl = get_author_posts_url( get_the_author_meta('ID'));
$authorDescriptionShort = wp_trim_words(strip_tags(get_the_author_meta('description')), $word_limit, $txt_end.'<br /> '.$more_txt.' '.$authorName.'');
return $authorDescriptionShort;
}

and then modify the code in td_module_single_base:
https://www.screencast.com/t/SY6pVugA0 to https://www.screencast.com/t/S17suezq

Thanks.

Post count: 25

ok, thanks !

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.