It’s pretty easy.
Usually your widget is supposed to be held on sidebar.php
In sidebar.php
you may have been call the function the_content()
to extract ‘About Me’ text.
In stead of calling the_content()
you need to call your own created function [suppose, read_more()
] which should be defined in functions.php
like this way:
function read_more($limit){
$post_content = explode(' ', get_the_content());
$less_content = array_slice($post_content,0, $limit);
echo implode(' ', $less_content);
}
Now, mentioning an argument, call the read_more()
function in anywhere you need, perhaps in sidebar.php
Note that, first, needs to make Query and then call the function this way:
<?php
$content_text = new WP_Query(array('post_type' => 'text'));
while($content_text->have_post()) : $content_text->the_post();
?>
<p> <?php read_more(15); ?> </p>
<p> <a href="https://wordpress.stackexchange.com/questions/266851/<?php the_permalink(); ?>"> Read More </a> </p>
<?php endwhile; ?>
where, integer value indicates 15 number of words to be shown up there.
That’s it.