0

I am using highlight search terms in my wordpress website. In my search result, the last character of the excerpt is as below:

This is the excerpt.[...]

I have the code in my functions.php which i got from Stackexchange.

function search_excerpt_highlight() {
    $excerpt = get_the_excerpt();
    $keys = implode('|', explode(' ', get_search_query()));
    $excerpt = preg_replace(
        '/(' . $keys .')/iu',
        '<span class="search-highlight"><u>\0</u></span>',
        $excerpt
        ) 
        . "<br/><div class='right'><a href='" 
        . get_permalink($post->ID) 
        . " '>Read more...</a></div>";
    echo '' . $excerpt . '';
}

function custom_excerpt_length( $length ) {
    return 25;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

How do i remove the "[ ]" in the excerpt and make it to "..." only? Any solutions?

0

Use the excerpt_more filter:

add_filter( 'excerpt_more', 'wpse174028_change_excerpt_more' );
function wpse174028_change_excerpt_more( $excerpt_more ) {
    return '...';
}
| improve this answer | |
  • My pleasure! Easy, if you already know what to do. @Jornes – Nicolai Jan 6 '15 at 1:06
  • Alright. I'm still new in wordpress. There are lots to ask and learn. Thanks again! @ialocin :) – Jornes Jan 6 '15 at 1:10

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.