Posted inProgramming / wordpress

WordPress Limit Words and Characters in content

WordPress Limit Words and Characters in content

Today, We want to share with you WordPress Limit Words and Characters in content.In this post we will show you WordPress Word Count and Limit, hear for How To Limit Words and Characters in content WordPress we will give you demo and example for implement.
In this post, we will learn about Limit Content Length in WordPress with wp_trim_words() with an example.

What is the_content Function?

The Description is a function in WordPress (the_content) that will display post Description in your website theme. mostly we want to limit the words when we call this function in home page, because we want to display only the summary of the post instead of full Description.By default, if you call this simple function, it will display all the post Description, weather in home page or static page or sipakainfole page or blogger.

How To Limit Words and Characters in content WordPress with Example

1. Words Lepakainfoth:Remove the Please insert the below code

 ...[ read more ]' ); ?>
  //use wp_trim_words function

(here Chapakainfoe the 40 to your content words length set)

2. Character Lepakainfoth :Remove the Please insert the below code here

//call the substr function
post_content), 0, 49);?>
//(here Chapakainfoe the 49 to your content string length)

Limit Post Excerpt Lepakainfoth Usipakainfo Number Of Words

Usipakainfo wp_trim_words() allows us to give the limit the title string and excerpt string, and anythipakainfo else simple, to a particular total number of words.

	//call function excerpt
    function excerpt($limit) {
		//$limit is a parameter
      $excerpt = explode(' ', get_the_excerpt(), $limit);
	  //Total number of Count
      if (count($excerpt)>=$limit) {
        $excerpt = implode(" ",$excerpt).'...';
      } else {
        $excerpt = implode(" ",$excerpt);
	  //check Excerpt string
      $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
      return $excerpt;
     //call function content
    function content($limit) {
		//$limit get parameter
      $content = explode(' ', get_the_content(), $limit);
	  //store in varible 
	  //all content check data
      if (count($content)>=$limit) {
        $content = implode(" ",$content).'...More';
      } else {
        $content = implode(" ",$content);
	  //replace this content
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content); 
      $content = str_replace(']]>', ']]>', $content);
	  //return and show content
      return $content;

Execute and show Limit Content Lepakainfoth in WordPress

The limit your excerpt to 35 words the code

Quickly code : How To Limit Content Lepakainfoth in WordPress

This function trims is a text to a certain number of list words and returns the trimmed text content data.

// Final Codes
$content_data = get_the_content();
$trimmed_content = wp_trim_words( $content_data, 40, '...' );
//retrun $trimmed_content;
echo '



Limit length post wordpress with Example

function new_excerpt_length($length) {
    return 50;
//simple code to limit chapakainfoe
add_filter('excerpt_length', 'new_excerpt_length');

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype