{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://coderseye.com/#website","url":"https://coderseye.com/","name":"Coders Eye - Web Dev Tutorials and How-To Guides for Beginners","potentialAction":{"@type":"SearchAction","target":"https://coderseye.com/?s={search_term_string}","query-input":"required name=search_term_string"}},{"@type":"ImageObject","@id":"https://coderseye.com/how-to-remove-from-the-from-excerpts-in-wprdress#primaryimage","url":"https://coderseye.com/wp-content/uploads/remove-excerpts-dots-from-wordpress.jpg","width":800,"height":500,"caption":"remove-excerpts-dots-from-wordpress"},{"@type":"WebPage","@id":"https://coderseye.com/how-to-remove-from-the-from-excerpts-in-wprdress#webpage","url":"https://coderseye.com/how-to-remove-from-the-from-excerpts-in-wprdress","inLanguage":"en-US","name":"How To Remove the [...] From Excerpts in WordPress - CodersEye.com","isPartOf":{"@id":"https://coderseye.com/#website"},"primaryImageOfPage":{"@id":"https://coderseye.com/how-to-remove-from-the-from-excerpts-in-wprdress#primaryimage"},"datePublished":"2016-02-17T04:44:00+00:00","dateModified":"2016-06-02T20:59:49+00:00","author":{"@id":"https://coderseye.com/#/schema/person/a56f7a71a0b69c1d5aad5ff1971f81ab"}},{"@type":["Person"],"@id":"https://coderseye.com/#/schema/person/a56f7a71a0b69c1d5aad5ff1971f81ab","name":"Stephanie Reigns","image":{"@type":"ImageObject","@id":"https://coderseye.com/#authorlogo","url":"https://secure.gravatar.com/avatar/9e9cb84680cc1ac746317f5391c51964?s=96&d=mm&r=g","caption":"Stephanie Reigns"},"description":"I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.","sameAs":[]}]}
HomeTutorialsHow To Remove the […] From Excerpts in WordPress

How To Remove the […] From Excerpts in WordPress

remove-excerpts-dots-from-wordpress

If you want to remove or customize the way excerpts are outputted you can apply a simple function to your child theme’s functions.php file. In most cases you’ll have a “recent posts” section on a website and instead of having […] at the end of excerpts you can switch to to “read more” hyperlinked to the post.

1. Open your theme’s functions.php file. Paste the following code.


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


This snippet will completely remove [...] from the excerpt.


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


This snippet will replace [...] with ...


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


This snippet will replace [...] with a read more hyperlinked to your post in your loop/query.

In some cases you wouldn't want to globally alter the excerpt feature on the site.


function change_excerpt( $more ) {
        if(post_type_exists('services')){
           return '';
        }
     return '...';
}
add_filter('excerpt_more', 'change_excerpt');


This snippet will replace only the 'services' custom post type excerpt [..] with a blank space, but for every other posts and page it will return ...

FOLLOW US ON:

I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.

NO COMMENTS

Sorry, the comment form is closed at this time.