I use two custom functions for my excerpts, the first modifies the length of the excerpt and the second allows me to use the_excerpt in two ways – with a read more link and without as long as the appropriate code is included while calling the_excerpt (see here).

When I use the traditional the_excerpt it generates three ellipses in brackets after it […] – how do I remove these brackets and ellipses to just display the_excerpt itself without any link when calling it in posts, but still using my code below for the read more link elsewhere?

// Excerpt
    // Changing excerpt length
    function new_excerpt_length($length) {
        return 25;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    // Changing excerpt more
    function new_excerpt_more($post) {
      remove_filter('excerpt_more', 'new_excerpt_more'); 
      return ' <a class="read_more" href="'. get_permalink($post->ID) . '">' . 'read more' . '</a>';
    }

1 Answer
1

You haven’t added the second filter, at least not in the code posted. If used, that filter will not print ellipses.

// Changing excerpt more
function new_excerpt_more($more) {
  global $post;
  remove_filter('excerpt_more', 'new_excerpt_more'); 
  return ' <a class="read_more" href="'. get_permalink($post->ID) . '">' . 'read more' . '</a>';
}
add_filter('excerpt_more','new_excerpt_more');

Notice the couple of changes I made to that function.

If you just want to strip the ellipses:

add_filter('excerpt_more','__return_false');

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *