STYLE SWITCHER

How To Limit Words and Characters in content WordPress

1. Words Length:

Remove  the <?php the_content();?>  insert the below code
<?php $content = get_the_content();
  $trimmed_content = wp_trim_words( $content, 60, '<a href="'. get_permalink() .'">...[ read more ]</a>' ); ?>
  <p><?php echo $trimmed_content; ?></p>
(Change the 60 to your desire words length)

2. Character Length :

Remove  the <?php the_content();?>  insert the below code
<?php echo substr(strip_tags($post->post_content), 0, 46);?>
//(Change the 46 to your desire string length)

Recent Article

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Keep your skills sharp, get informed.

    Subscribe to our mailing list and get interesting stuff and updates to your email inbox