Hmm–are specifing the number of words for the excerpt with a filter or plugin. If so, might provide that code and maybe someone can spot the problem.
Related:
Excerpt
Template_Tags/the_excerpt
http://wordpress.org/extend/plugins/advanced-excerpt/
http://wordpress.org/extend/plugins/excerpt-editor/
Thread Starter
ambius
(@ambius)
I’m not using any plugins that affect post content or excerpts.
this is the very simple code I’m using
<? query_posts('posts_per_page=10&caller_get_posts=1');
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
if( have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<div class="post-title"><a>" rel="bookmark" title="Permanent Link to <? the_title_attribute(); ?>"><? the_title(); ?></a></div>
<div class="post-date"><? the_date('F j, y') ?></div>
<div class="post-content"><? the_excerpt() ?></div>
<div class="post-footer">POSTED BY <? the_author() ?> and last updated on <? the_modified_time('F jS, Y'); ?> at <? the_modified_time('g:i a'); ?>
<? comments_popup_link('« 0 Comments »', '1 Comment', '% Comments'); ?>
</div>
</div>
<p> </p>
<? endwhile; endif; //end the loop ?>
and here is the page on my test server if you want to see the wordcount outputs for yourself
http://uofmbooks.com/wordpress/
the first 7 posts are fine, but the 8th post “Minutes for 2-1-10” contains 30 words. Minutes for 10-27 has 22 words. etc…
Here’s the 2.9 core function that does that:
function wp_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . $excerpt_more;
}
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
I have noticed this too and after some experimenting I think I have found the cause.
If you have extra spaces between words those spaces will get counted as words. It’s easy to overlook as when editing using the visual editor the hidden spaces are not shown, you have to go into the html editor to see them.
Clearly it’s a wordpress bug as it should ignore the extra spaces, but at least there is a work around, albeit a rather tedious post editing one.