0

My website is watersedgeofshelton.com and i need help removing the [...] after the excerpts on the blog posts (under activities, marinas and restaurants"

I read that I had to add this code to my functions php

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

but when i added that, it did not work, any suggestions?

my functions php looks like this

// The excerpt based on words
if ( !function_exists('my_string_limit_words') ) {
    function my_string_limit_words($string, $word_limit){
        $words = explode(' ', $string, ($word_limit + 1));
        if( count($words) > $word_limit )
            array_pop($words);
        return implode(' ', $words).'...';
    }
}


// The excerpt based on character
if ( !function_exists('my_string_limit_char') ) {
    function my_string_limit_char($excerpt, $substr=0){
        $string = strip_tags(str_replace( '...', '...', $excerpt));
        if ( $substr > 0 ) {
            $string = substr($string, 0, $substr);
        }
        return $string;
    }
}
  • Your first code (add_filter('excerpt_more', '...');) works for me – Pierre Jun 16 '16 at 15:48
  • @Pierre where do i place this in the functions file? – sara Jun 16 '16 at 15:50
  • Yep! Where did you put this forward? – Pierre Jun 16 '16 at 15:52
  • @Pierre do i put it after the <?php – sara Jun 16 '16 at 16:21
1

This has to work, Im using it in several projects:

add_filter( 'excerpt_more', 'my_excerpt_more' );

function my_excerpt_more( $more ) {

    return '';
}

Just copy-paste it to your functions.php.


Little bonus snippet that you might need:

add_filter( 'excerpt_length', 'my_excerpt_length' );

function my_excerpt_length( $length ) {

    return 50;
}

This means that excerpt is 50 words long. Just modify the number to get different length.

  • do i add this just after the <?php ? – sara Jun 16 '16 at 16:14
  • Attention the hook excerpt_length returns a number of words and not characters ;-) – Pierre Jun 16 '16 at 16:23
  • @sara Im personally adding filters to the end of functions.php. – N00b Jun 16 '16 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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