Thank you for your help!


function excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
$excerpt = implode(" ",$excerpt);
} else {
$excerpt = implode(" ",$excerpt);
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;


<div class="post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">
  • 1
    Please decide yourself of which of those other questions yours is a duplicate of. About your php tag: Nearly every question about WordPress is a PHP question, so please don't use that tag - find a better one (or multiple). Question: What does the index.php line about the classes has to do with the excerpt length? And last, please tell us what your actual problem is. "Thank you for your help!" does add no information to the question, still it is the only full sentence in it. – kaiser Oct 24 '13 at 4:02
function custom_excerpt_length( $length ) {
  return 20;
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Add above code to your functions.php, and set the value 999 to the desired length.

Source: the_excerpt() — Codex

  • 999 isn't the 'desired length' of the excerpt required, that's the priority of the filter. It's the '20' bit you want to change. – BIOSTALL Jan 21 '18 at 17:22
  • @BIOSTALL You are aware you're replying on a comment made in 2013, right? Things probably have changed in the last 5 years. – Martin van Houte Jan 22 '18 at 8:28

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