Changing excerpt

Changing excerpt lenght

In WordPress it is possible to change the excerpt length by simply returning the desired number of words as an integer. In this example we will output the first 75 words. Create a variable an put it on top of your functions.php so you can quickly change it.

// Changing excerpt length to 75 Words
$wp_excerpt_words_length = 75;
function change_excerpt_length($length) {
   return $wp_excerpt_words_length;
add_filter('excerpt_length', 'change_excerpt_length');

Changing excerpt more

The default text appended to auto-generated excerpts is (‘[…]’). Sometimes it is more suitable to change it with something else for example a link. Here below is the code to change the excerpt more with a link.

// Changing excerpt more
function change_excerpt_more($more) {
   return '<a title="Continue reading" href="%27.%20get%20permalink%28%29%20.%20%27" rel="nofollow">' . 'Continue reading' . '</a>';
add_filter('excerpt_more', 'change_excerpt_more');







Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *