4

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

11

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');
1
  • 1
    I had to remove Line 2 of the function, otherwise it only replaced the first [...] and then printed them for all posts after.
    – rob-gordon
    Commented Mar 24, 2015 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.