content limit in wordpress – How To Limit Words and Characters in content WordPress?

content limit in wordpress using Words Length and Character Length Example – in this article you can use get_the_content() function contains wordpress content page/post content.

content limit in wordpress

There are many ways to limit the WordPress post content length. Like as a wp_trim_words, substr and many more. Also you can check my prev post is a WordPress Limit Words And Characters In Content

How to set character limit on the_content() and the_excerpt() in wordpress?

<?php   
  add_filter("the_content", "custom_Plugin_CodeFilter");

  function custom_Plugin_CodeFilter($content)
  {
    return substr($content, 0, 120);
  }
?>

Example : Words Length:

Remove the insert the below PHP code

<?php $content = get_the_content();
  $trimmed_content = wp_trim_words( $content, 120, '<a href="'. get_permalink() .'">...[ read more ]</a>' ); ?>
  <p><?php echo $trimmed_content; ?></p>

Read Also:  Display Posts From Specific Category On A WordPress Page

Note : You can Change the 120 to your desire words length

Example : Character Length

Remove the insert the below PHP code

<?php echo substr(strip_tags($post->post_content), 0, 110);?>

Note : You can Change the 110 to your desire string length

Don’t Miss : Php Limit String To 50 Characters

How to limit WordPress Post content length?

<?php
$article_data = substr(get_the_content(), 0, 120);
echo $article_data;
?>

it will pass it to php substr() function to limit the content to 120 characters.

I hope you get an idea about content limit in wordpress.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.