Title: excerpt_length
Last modified: August 20, 2016

---

# excerpt_length

 *  Resolved [VigridDesign](https://wordpress.org/support/users/vigriddesign/)
 * (@vigriddesign)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/excerpt_length/)
 * Hello Everyone,
 * This is my first post so please bare with me and I apologise if this is perhaps
   the wrong forum for this thread. I am looking for some advice and where possible
   help in dealing with the excerpt_length function which I have recently added 
   to my theme’s function file. The problem is that that cuntion only seems to be
   shortening the excerpt of the first post and the rest are staying at their maximum
   output.
 * **functions.php**
 *     ```
       function custom_excerpt_length( $length ) {
       	return 40;
       }
       add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
       ```
   
 * I got the above code from the codex part of this site and like I said it seems
   to work but for some reason only on the first post. Here is the code from my 
   homepage for the post list, I cannot find anything abnormal but a second opinion
   is always helpful.
 *     ```
       <!-- Content Start -->
       <section id="content" class="base">
         <section class="sidebar">
           <?php include(TEMPLATEPATH. '/sidebar.php');?>
         </section><!--/sidebar-->
         <ul class="posts">
           <?php
             $temp = $wp_query;
             $wp_query= null;
             $wp_query = new WP_Query();
             $wp_query->query('showposts=6'.'&paged='.$paged);
           ?>
           <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
   
       <li>
             <div class="listbox">
               <div class="postthumb">
                 <a>" title=" <?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
               </div><!--/postthumb-->
               <div class="postdata">
                 <h2><a>" title=" <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                 <?php the_excerpt();?>
               </div><!--/postdata-->
            </div><!--/listbox-->
           </li>
       <?php endwhile; ?>
   
       <li>
             <div class="pagination">
               <?php previous_posts_link('<div class="left smallbutton">Previous</div>') ?>
               <?php next_posts_link('<div class="right smallbutton">More</div>') ?>
             </div><!--/pagination-->
           </li>
       <?php $wp_query = null; $wp_query = $temp;?>
       <div class="cleared"></div>
       </section><!--/content/page-->
       <!-- /Content End -->
       ```
   
 * I am at a loss with this and nothing I try seems to work and so I would welcome
   an suggestions and or solutions to this problem. Just to summarise the excerpt_length
   is only shortening the first posts excerpt the rest are being spat out at their
   full allowed character amount.

Viewing 1 replies (of 1 total)

 *  Thread Starter [VigridDesign](https://wordpress.org/support/users/vigriddesign/)
 * (@vigriddesign)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/excerpt_length/#post-2676044)
 * I have resolved the issue thanks. Some posts had manual excerpts in them that
   I had not noticed and this was overwriting any attempt to use excerpt_length.

Viewing 1 replies (of 1 total)

The topic ‘excerpt_length’ is closed to new replies.

## Tags

 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)
 * [excerpt_length](https://wordpress.org/support/topic-tag/excerpt_length/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [VigridDesign](https://wordpress.org/support/users/vigriddesign/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/excerpt_length/#post-2676044)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
