WordPress.org

Support

Support » Plugins and Hacks » Remove the suffix dot from the excerpt

Remove the suffix dot from the excerpt

  • I’m wanting to remove the suffix dots at the end of the excerpt, how can I go about doing this? Preferably via functions.php in my theme…

Viewing 1 replies (of 1 total)
  • You just need to add this code to functions.php file:

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

    Or if you want that […] to became just … You can add this:

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

    Might be you want to change the dots with a read more link to the article. Than you can add this code:

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

    Good luck with your theme!

    [spam link removed]

Viewing 1 replies (of 1 total)
  • The topic ‘Remove the suffix dot from the excerpt’ is closed to new replies.
Skip to toolbar