Though it’s a bit of unnecessary things to answer your actual question, but for the fact, I used the following code into many of my News Portal WordPress sites, where I had the facilities to Control the excerpt length, and I changed the excerpt More link to my choice. All I did was using my new function echo nano_excerpt(50)
instead of using the_excerpt()
.
<?php
/**
* Change the excerpt length to some extent
* where the default is 55.
*
* @param integer $length
* @return integer
*/
function custom_excerpt_length( $length ) {
return 200;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
/**
* Change the excerpt 'more'
* @return string
*/
function new_excerpt_more() {
return '... <a class="read-more" href="'. get_permalink( get_the_ID() ) .'">'. __( '»', 'your-theme' ) .'</a>';
}
/**
* The excerpt filters
* @param integer $limit max limit of words to show
* @return string
*/
function nano_excerpt( $limit = 75 ) {
$limited_excerpts = wp_trim_words( get_the_excerpt(), $limit, new_excerpt_more() );
return $limited_excerpts;
}
Just paste ’em into your functions.php
and use the new function echo nano_excerpt($limit)
– mentioning the limit of words you want, or leave it blank to show the default 75 words.
Source: http://codex.wordpress.org/Function_Reference/the_excerpt