How to Change WordPress Excerpt Ellipsis

When first creating a WordPress theme, there is a checklist I usually go to through to make basic customizations for a better overall UX. One thing that gets on my nerves is that set of obnoxious default set of ellipsis surrounded by brackets at the bottom of an excerpt. If you happen to develop anything for WordPress, you know what I’m talking about.  The dreaded […] that sticks like a bug to the end of some article teasers.

In this article, I’ll show you some quick and easy ways of customizing the end of the excerpt by changing the excerpt ellipsis in WordPress.

How to Change Excerpt Ellisis in WordPress

This whole process is actually rather simple. You’ll need to add the following code into your functions.php file.

function new_excerpt_more($more) {
    return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');

This code will replace the ugly version of WP excerpt ellipsis of […] with a very basic (you’ll notice the lack of the ugly brackets). With this code, there’s more possibilities available than just modifying excerpt ellipsis. If you’re at least an intermediate WordPress developer, you’ll realize you can customize this function to include a “Read More” link at the end of an excerpt.

Instead of just modifying the ellipsis, you can drop the following code into functions.php to create a “Read More” or “Read On” link at the bottom of any of your WordPress excerpts.

function new_excerpt_more($more) {
  return ' <a class="read-more" href="' . get_permalink( get_the_ID() ) . '">Read More</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

As you may have discovered, removing the excerpt ellipsis on a WP teaser is a small task that is extremely useful to help further beautify your UI. Go ahead and take the code from above to create your own excerpt endings.

 

1 thought on “How to Change WordPress Excerpt Ellipsis”

Comments are closed.