WordPress.org

Ready to get started?Download WordPress

Forums

Remove the suffix dot from the excerpt (2 posts)

  1. ibeats
    Member
    Posted 5 years ago #

    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...

  2. Mr. Vibe
    Member
    Posted 4 years ago #

    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]

Topic Closed

This topic has been closed to new replies.

About this Topic