I use a theme that have a character limit for shortpost and show [...] at the end of character limit.

I want to remove this, so I search for the_excerpt(); and replace with the_content();

The problem solve with normal content but still have problem with image post type and there is <?php the_excerpt(); ?> that when I change this my shortpost act like full post and it's not related to the length of post.

I try to open all PHP files in theme and looking for key words like: limit, length, excerpt for find where is the code that define the length of shortpost even search for "[...]" in all files and language but I don't know where is that come from.

But all I find is some line of code in function.php

if ( ! function_exists( 'string_limit_words' ) ) :
function string_limit_words($str, $limit = 18 , $need_end = false) {
    $words = explode(' ', $str, ($limit + 1));
    if(count($words) > $limit) {
    return implode(' ', $words);

And when I increase 18 nothing change!

What code I must looking for?

6 Answers 6


The codex is your friend and should be your first stop :-)

The [...] is added by the_excerpt(). There is a filter supplied called the excerpt_more filter that is specifically included to customize the read more text after the excerpt

To remove the [...] after the excerpt text, you can do the following

function new_excerpt_more( $more ) {
    return '';
add_filter('excerpt_more', 'new_excerpt_more');
  • thanks for reply your code is work well for remove [...] , but still the shortpost are limited and word cut after some characters I want act normal ( everything before read more tag show on my short post )
    – Arioman
    Sep 21, 2014 at 15:00
  • another Question just for curious , how can i change the [...] to some thing else for example [ more ... ]
    – Arioman
    Sep 21, 2014 at 15:00
  • You should read this post. I've covered about everything in that post. Hope it helps :-). Remeber to accept my answer if it helped solving your issue. Sep 21, 2014 at 15:04
  • this seems to only remove the read more link. The [...] is still there.
    – Jules
    Sep 21, 2017 at 8:02
  • Great, this is working also for Query loop excerpt block in Gutenberg editor.
    – Iggy
    Sep 25, 2022 at 0:20

As others have already pointed out, using the excerpt_more filter hook is the right way to go.

Just wanted to add that you don't have to write a function that returns an empty string. WordPress has a few built in functions to return true, false, zero, null, empty string or empty array.

In this case we need __return_empty_string()

You can add this code to your plugin or to your theme's functions.php:

// This will add a filter on `excerpt_more` that returns an empty string.
add_filter( 'excerpt_more', '__return_empty_string' ); 

You should add this to your functions.php

    function custom_excerpt_more( $more ) {
    return '';//you can change this to whatever you want
add_filter( 'excerpt_more', 'custom_excerpt_more' );

Also, using the_excerpt has the advantage that automatically cleans the content, and deletes all images, and other HTML tags.

You can read more here

If you also want to modify the length of the excerpt, you can add this snippet to your functions.php:

function custom_excerpt_length( $length ) {
    return 20;//change the number for the length you want
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

You can read more about this here

  • Which versions are you targeting, that is pre 2.9 :-) Sep 21, 2014 at 12:17
  • @PieterGoosen, I guess the wrong one.
    – Tomás Cot
    Sep 21, 2014 at 12:20
  • your code work well with changing length but when i remove [...] it will be ugly when a part of paragraph looks missing it will be great if somehow detect a paragraph instead lenght !! // another problem with excerpt is about shortcodes , i cant put video player or slideshow to my short post
    – Arioman
    Sep 21, 2014 at 15:14
  • @Arioman, you can change the [...] with a link that says "Keep reading", or whatever you want. Now, if you want to have working shortcodes, the_excerpt isn't what you are looking for, you should add that to the question, as the answers will change.
    – Tomás Cot
    Sep 21, 2014 at 15:26
  • @TomásCot thanks for this fantastic guide . i put all codes (complete code) in my function.php and remove $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); for accept all tags i use stream video player for insert video and it generates shortcodes like : [stream flv=http://****/clip/shad.m4v embed=false share=false width=640 height=360 dock=true controlbar=over bandwidth=high autostart=false responsive=16:9 /] but still i get a text : *Video: my video instead of showing my video player in shortpost where is my problem ??
    – Arioman
    Sep 22, 2014 at 6:34

that is work for me !

function change_excerpt( $text )
    $pos = strrpos( $text, '[');
    if ($pos === false)
        return $text;

    return rtrim (substr($text, 0, $pos) );
add_filter('get_the_excerpt', 'change_excerpt');

'excerpt_more' is a WordPress hook. It returns the content excerpt. To remove the [...] after the excerpt text, you can return blank like below or your custom requirements. Use this code on function.php

function custom_excerpt_more( $excerpt ) {
    return '';
add_filter( 'excerpt_more', 'custom_excerpt_more' );

Try to create a new function in your functions.php:

function custom_excerpt() {
 $text=preg_replace( "/\\[&hellip;\\]/",'place here whatever you want to replace',get_the_excerpt());
echo '<p>'.$text.'</p>';

Then use the new function on your page.

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.