WordPress Function to Custom excerpt length

Custom excerpt length

function excerpt($num) {
    $limit = $num+1;
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    $excerpt = implode(" ",$excerpt)."... (<a href='" .get_permalink($post->ID) ." '>Read more</a>)";
    echo $excerpt;

Limit the length of the displayed excerpt by writing in the theme: excerpt(’20’);

Example: <?php excerpt('22'); ?>
This will limit the excerpt to 22 characters.

The excerpt will be interupted with ... (Read More)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *