How to remove the suffix dot from the excerpt

Well, I’m sure those of you who are using WordPress themes that displays the excerpt wanted to know how can you remove the suffix dot from the excerpt. What is suffix dot from the excerpt? This little thing that appears after each partial content displayed on your index or archive page and it looks like this […]

You can install a plugin to remove those suffix dots but is it really necessary? It is just a matter of copy and paste of one of the following codes in your “functions.php” file that is located in the folder of your WordPress theme. Let’s get started:

Method 1. If you want to complete remove the suffix dot add the following code to functions.php

function trim_excerpt($text)
{
return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'trim_excerpt');

Method 2. If you want to change the […] with this … add the following code to your functions.php

function trim_excerpt($text)
{
return str_replace(' [...]', '...', $text);
}
add_filter('get_the_excerpt', 'trim_excerpt');

Method 3. If you want to change the suffix dot with a “read more” link, than add this code to your functions.php file:

function trim_excerpt($text)
{
return str_replace(' [...]', '<a href=" . get_permalink() . ">' . ' read more...</a>', $text);
}
add_filter('get_the_excerpt', 'trim_excerpt');

That’s about it… you really don’t need a plugin for this.

One comment

  1. newager says:

    Thanks for the advice, it saves a lot load time not bother with a plugin, i have used method two which works fine but could not get method three to function but it could be my template.

Leave a Reply

%d bloggers like this: