Limiting WP Post content and adding conditional Read More button

Content limit 110 words.

<?php $trimexcerpt = get_the_content();
$shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 110, $more = ' [...]' );
echo "<p>" .$shortexcerpt. "</p>";
?>

After 110 words show “Read More”

<?php
$count = str_word_count($shortexcerpt);

if($count >= 110){ ?>
    <a href="<?php the_permalink(); ?>" class="st-more-link text-center
 text-uppercase"><span><?php _e('Read More', 'cherry') ?></span></a>
<?php } ?>

Leave a Reply