WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok i have this code currently.



echo "<div id='widgets-wrapper2'><div id='marginwidgets' style='overflow: auto; max-    width: 100%; height: 450px; max-height: 100%; margin: 0 auto;'>";
while (have_posts()) : the_post();
echo "<div class='thewidgets2'>";

echo wp_trim_words( the_content(), $num_words = 0, $more = "..." );

echo '<div style="height: 20px;"></div><a class="button2"     href="'.get_permalink().'">Read More</a></div>';
echo "</div></div>";


as you can see, it gets all the post from the category name widgets2 and then it should display it.

and this line

echo wp_trim_words( the_content(), $num_words = 100, $more = "..." );

should trim the words from the_content() to 100 and add a excerpt at the end character but unfortunately it doesnt work, instead it just display the entire contents that looks untrim at all.

Hope someone here could figured out. Im open in any suggestions, recommendations and all relevant ideas, thank you.

share|improve this question
It's says 0 in your code example instead of 100. Also you don't need variables in function call, just echo wp_trim_words( the_content(), 100, '...' ); – Rarst Oct 15 '12 at 22:45
possible duplicate of limit the words in the post content and add read more link – kaiser Oct 15 '12 at 22:55
Why don't you simply stick to your old question? Comment, make progress. – kaiser Oct 15 '12 at 22:56
up vote 1 down vote accepted

the_content echoes post content. It does not return a string that you can manipulate. You need get_the_content() Swap those functions and it should work.

share|improve this answer
thank you. this difinetly what im looking for. – Juliver Galleto Oct 15 '12 at 23:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.