Title: Difficulty limiting post excerpts
Last modified: August 20, 2016

---

# Difficulty limiting post excerpts

 *  Resolved [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/)
 * Hi All,
 * I have looked for a solution to my problem and although i have seen code such
   as adding this to functions.php:
 *     ```
       function limit_words($string, $word_limit) {
   
       	// creates an array of words from $string (this will be our excerpt)
       	// explode divides the excerpt up by using a space character
   
       	$words = explode(' ', $string);
   
       	// this next bit chops the $words array and sticks it back together
       	// starting at the first word '0' and ending at the $word_limit
       	// the $word_limit which is passed in the function will be the number
       	// of words we want to use
       	// implode glues the chopped up array back together using a space character
   
       if (count($words) > $word_limit ) {$end = '…';}
   
       return implode(' ', array_slice($words, 0, $word_limit)). $end;
       }
       ```
   
 * and this in my blog.php: ` <?php echo limit_words(get_the_excerpt(), ’10’); ?
   >
    ` The link is [http://test.akeytodesign.com/blog/](http://test.akeytodesign.com/blog/)
 * Help is much appreciated!
 * Thanks

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/page/2/?output_format=md)

 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336184)
 * I see a few ways that work on [this thread](http://wordpress.org/support/topic/limit-the-number-of-words-in-excerpt-without-plugins).
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336188)
 * Thanks Aaron, I did see that but it seems to only take a snippet of the excerpt
   off. I wonder if it is the placement of the code but this is how the code looks
   after I’ve put it in.
 *     ```
       <div id="blogpage">
       	<?php query_posts('posts_per_page=2'); ?>
           <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
   
               <div class="post-block-blog">
   
               <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
              <p class="post-date"><?php the_time('j M Y'); ?></p>
   
               <?php the_content(); ?>
   
       		<?php
                 $excerpt = get_the_excerpt();
                 echo string_limit_words($excerpt,25);
               ?>
   
             <p class="readmore"> <a href="<?php the_permalink(); ?>" title="Continue reading this article">Read more</a></p>
               </div>
       		<?php endwhile; ?>
       ```
   
 * I have even reduced and increased the number just to see where I could be going
   wrong… but still cant figure it out! :s
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336195)
 * What exactly are you trying to accomplish?
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336199)
 * I’m trying to accomplish having just a preview of my blog posts visible on the
   blog page.
 * See this link- [http://test.akeytodesign.com/wp-content/uploads/2013/01/Yato-Blog-excerpt.jpg](http://test.akeytodesign.com/wp-content/uploads/2013/01/Yato-Blog-excerpt.jpg)
 * Right now, it’s displaying the entire blog post and I want it to show as above.
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336201)
 * This is how I always do it.
 * Find
 * `<?php the_content(); ?>`
 * change to
 * `<?php the_excerpt(); ?>`
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336204)
 * So to clarify, would you write it as the link demonstrates but just changing 
   the above?
 * I have an image in my content so would this be affected?
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336207)
 * Yes just change the word content to excerpt.
 * You will not see the image in the excerpt. They would need to click through to
   the actual page/post to see it.
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336209)
 * Thank you. Yes, I changed it and although it looks good, that image needs to 
   display as I showed in the link.
 * I’d need it to show the image associated with the post and an excerpt underneath.
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336210)
 * Above the excerpt code add this.
 *     ```
       <?php if ( has_post_thumbnail() ) {
         the_post_thumbnail();
       } ?>
       ```
   
 * Now go back in your post and on the right side set the Featured Image. What this
   code does is display whatever image is set as the Featured Image in the post.
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336211)
 * Awesome! Works brilliantly, thanks Aaron. 🙂
 * Lastly, can I amend how much of that excerpt is displayed?
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336212)
 * Go in and edit your post and where you want it to cutoff put the below code.
 * `<!--more-->`
 * There is also a button for that code in the HTML editor.
 *  Thread Starter [Graycode](https://wordpress.org/support/users/graycode/)
 * (@graycode)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336217)
 * It works but not accurately.
 * I used the Visual editor to place that code in but its like it cuts it off but
   adds the rest to the end lol.
 * I’ve added several spaces where the space is meant to be so you can see what 
   i mean. [http://test.akeytodesign.com/blog/](http://test.akeytodesign.com/blog/)
 * If its an unnecessary hassle, I can leave it but I’d like to be as accurate to
   that image i showed you as possible.
 * You’ve been so helpful thank you.
 *  [Anoodles](https://wordpress.org/support/users/anoodles/)
 * (@anoodles)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336304)
 * hey guys i ve been having difficulty to find the excerpt part because all i can
   find is ‘content’.
    IT changed really sudden when i changed the backround pic
   in simple catch theme and from full post it only shows an excerpt… i ve tried
   to find it but i cant… please help!!!
 *  [Anoodles](https://wordpress.org/support/users/anoodles/)
 * (@anoodles)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336316)
 * oh the site is this if anyone would like to help me!
    [http://www.tincturetales.com/](http://www.tincturetales.com/)
 *  [WP Libra](https://wordpress.org/support/users/wpbum/)
 * (@wpbum)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/#post-3336317)
 * Anoodles,
 * You would need to start your own topic for what problems you are having, not 
   jump in on someone elses.

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/page/2/?output_format=md)

The topic ‘Difficulty limiting post excerpts’ is closed to new replies.

## Tags

 * [blog post](https://wordpress.org/support/topic-tag/blog-post/)
 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)
 * [Word Limit](https://wordpress.org/support/topic-tag/word-limit/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 19 replies
 * 4 participants
 * Last reply from: [Graycode](https://wordpress.org/support/users/graycode/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/difficulty-limiting-post-excerpts/page/2/#post-3336325)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
