Tip: How to change the default WordPress excerpt


Ever get tired of those nasty [...] ellipses that appear beneath your blog excerpts? I do. In this tutorial, I am going to show you how to change WordPress’ default excerpt display without changing core WordPress files.

Open up functions.php and add this code to the very bottom of the file:

<?php function gpp_excerpt($text) { return str_replace('[...]', '<br /><a href="'.get_permalink().'">Read More &rarr;</a>', $text); } add_filter('the_excerpt', 'gpp_excerpt'); ?>

The above code “filters” WordPress’ default the_excerpt function and replaces it with our own gpp_excerpt function. We have just written a very simple plugin for WordPress.

If, however, you are writing your own excerpts and want to add a Read More permalink, replace:

<?php the_excerpt(); ?>

with this:

<?php the_excerpt(); ?><span class="read_more"><a href="<?php the_permalink(); ?>">[ Read More &rarr; ]</a></span>

If you found this tutorial useful, consider subscribing to Graph Paper Press. You will get access to our support forum, where additional tutorials similar to this one are available to our subscribers.

This entry was posted in Blog and tagged , . Bookmark the permalink.

Posted by , at Graph Paper Press

Thad is a photographer, designer and developer who embraces the evolution of storytelling on the web. He lives in Brooklyn, NY with his wife Abby.

  • Google
  • Blog
  • Instagram

Create a WordPress theme in 60 seconds

No coding required!

Create a theme

  • Natalie Wi

    To which “functions.php” file should this code be added? To the one in “wp-includes” or the one in the theme folder?

    • http://graphpaperpress.com Thad

      You make the changes on the functions.php file in your theme folder. You should never touch the WordPress files, unless you are a serious developer.

  • Natalie Wi

    To which “functions.php” file should this code be added? To the one in “wp-includes” or the one in the theme folder?

    • http://graphpaperpress.com Thad

      You make the changes on the functions.php file in your theme folder. You should never touch the WordPress files, unless you are a serious developer.

  • http://www.allurewest.com/blog Natalie Wi

    Great–I’ll give it a try. Thanks!

  • http://www.allurewest.com/blog Natalie Wi

    Great–I’ll give it a try. Thanks!

  • http://www.explosivewebdesign.com/ Effective Web Design

    Very useful tips, thank you.

  • http://www.explosivewebdesign.com/ Effective Web Design

    Very useful tips, thank you.

  • http://belosic.com/advertising_portfolio.html Belosic – Reno Graphic Design

    Cool…thank you! Super easy, and it works! Now to make a widget that will do it… :)

  • http://belosic.com/advertising_portfolio.html Belosic – Reno Graphic Design

    Cool…thank you! Super easy, and it works! Now to make a widget that will do it… :)

  • Eli

    thanks, works like a charm, now my issue is to add post pic!

  • Eli

    thanks, works like a charm, now my issue is to add post pic!

  • Pingback: qqqqqqqqqq « Test Industrial Blog

  • http://www.SpicyLogo.com Custom Logo Design

    I am not too good in coding. Now as you have told this function but can you also let know how we can change or customize the theme our way. Like if we want the menu bar to be in different way..

  • http://www.SpicyLogo.com Custom Logo Design

    I am not too good in coding. Now as you have told this function but can you also let know how we can change or customize the theme our way. Like if we want the menu bar to be in different way..

  • http://jamesspratt.org JamesSpratt.org

    Nice one, works a dream. Thank you.

  • http://jamesspratt.org JamesSpratt.org

    Nice one, works a dream. Thank you.

  • http://www.begamo.com begamo

    This is simple but useful tips, thanks.

  • http://www.begamo.com begamo

    This is simple but useful tips, thanks.

  • http://workathomewhynot.com ALAN

    What a great site for info, I am a novice, The info gained here I can put in my log and reuse in time.Thank you

  • http://workathomewhynot.com ALAN

    What a great site for info, I am a novice, The info gained here I can put in my log and reuse in time.Thank you

  • http://workathomewhynot.com Kate

    As I learn more I will always remember that I started here. Thank you for all the info I can put it to use in my business plan.Our site please check us out

  • http://workathomewhynot.com Kate

    As I learn more I will always remember that I started here. Thank you for all the info I can put it to use in my business plan.Our site please check us out

  • http://www.4oo2.com/ 4oo2.com

    Thank you for all the info

  • http://www.4oo2.com/ 4oo2.com

    Thank you for all the info

  • http://www.4oo2.com/ 4oo2.com

    Thanks for the nice information

  • http://www.4oo2.com/ 4oo2.com

    Thanks for the nice information

  • http://noticia787.com education

    thanks for your article

    it is a nice blog

  • http://noticia787.com education

    thanks for your article

    it is a nice blog

  • http://asklyndondavid.com/ Lyndon

    This is very detailed. Thanks for teh screenshots.

  • http://asklyndondavid.com/ Lyndon

    This is very detailed. Thanks for teh screenshots.

  • http://www.aybareklam.com tabela

    share this issue with us, thank you to my friends. Have very good information on this site.
    good work

  • http://www.aybareklam.com tabela

    share this issue with us, thank you to my friends. Have very good information on this site.
    good work

  • Pingback: Tip: How to change the default Wordpress excerpt | Tutorials and wordpress

  • http://www.netage.co.za/pages/design Jacques | Web Design

    The community using, supporting and developing WordPress just has soooo much to offer. Simple things like this is a real treat to non-developer types like me, and to have figured it out on my own (using another platform without the enthusiast community to back it) would’ve been a big task. Thank you for saving us time (and indirectly, money)!!!

  • http://www.netage.co.za/pages/design Jacques | Web Design

    The community using, supporting and developing WordPress just has soooo much to offer. Simple things like this is a real treat to non-developer types like me, and to have figured it out on my own (using another platform without the enthusiast community to back it) would’ve been a big task. Thank you for saving us time (and indirectly, money)!!!

  • http://www.greatpressrelease.com Submit My Article

    Wow, that was easy. thank you.

  • http://www.greatpressrelease.com Submit My Article

    Wow, that was easy. thank you.

  • http://www.theimagemaster.com Dave

    Thanks!
    How can I change the tag
    to something else like “read more”?

  • http://www.theimagemaster.com Dave

    Thanks!
    How can I change the tag
    to something else like “read more”?

  • Pingback: How to Change the [...] in Wordpress’ the_excerpt Hook | The Mighty Mo! Design Co. | Minneapolis Wordpress Developers and Designers

  • http://www.designersalestore.co.uk Craig

    Very useful tip that will come in very handy. Many Thanks

  • http://www.designersalestore.co.uk Craig

    Very useful tip that will come in very handy. Many Thanks

  • http://www.commercialphotographystudiowales.co.uk richard p walton

    Please HELP!!!

    I put this in the bottom of the functions.php but nothing happened so i put it up inbetween the very last arrow and question mark and my sites broken?

    http://www.commercialphotographystudiowales.co.uk

    it’s coming up blank and I can’t login via the /wp-admin either

    I’ve looked at the function.php in my ftp software but there seems to be far more stuff in there than there was when looking at it on internet through apperance/ editor on wordpress.

    please help

    Thank you very much!

  • http://www.commercialphotographystudiowales.co.uk richard p walton

    Please HELP!!!

    I put this in the bottom of the functions.php but nothing happened so i put it up inbetween the very last arrow and question mark and my sites broken?

    http://www.commercialphotographystudiowales.co.uk

    it’s coming up blank and I can’t login via the /wp-admin either

    I’ve looked at the function.php in my ftp software but there seems to be far more stuff in there than there was when looking at it on internet through apperance/ editor on wordpress.

    please help

    Thank you very much!

  • http://www.localgrain.org/fieldsandfire/ Seth

    Thank you! That was an excellent tip.

  • http://www.localgrain.org/fieldsandfire/ Seth

    Thank you! That was an excellent tip.

  • http://www.metacomdesign.com/blog MetacomCreative

    Yet another way. It’s tough to decide which to use, haha. This one does seem easy to implement tho. Thanks for the post

  • http://www.metacomdesign.com/blog MetacomCreative

    Yet another way. It’s tough to decide which to use, haha. This one does seem easy to implement tho. Thanks for the post

  • http://www.diziizlek.com Dizi izle

    Thanks!
    How can I change the tag
    to something else like “read more”

  • http://www.diziizlek.com Dizi izle

    Thanks!
    How can I change the tag
    to something else like “read more”

  • http://www.oyunlarda.com Oyunlar

    i will try. thnx

  • http://www.oyunlarda.com Oyunlar

    i will try. thnx

  • http://www.telefondinlemeprogrami.com telefon dinleme

    Yes i think these codes will be useful for me . try it soon.

  • http://www.telefondinlemeprogrami.com telefon dinleme

    Yes i think these codes will be useful for me . try it soon.

  • http://danwiersema.com Dan Wiersema

    Extremely helpful, thanks so much!

  • http://danwiersema.com Dan Wiersema

    Extremely helpful, thanks so much!

  • http://bydeo.com Deo

    After my installed excerpt plugin didn’t work, I use your code and it works like charms.. thank you

  • http://bydeo.com Deo

    After my installed excerpt plugin didn’t work, I use your code and it works like charms.. thank you

  • Paul

    Awesome… I’ve been looking for something like this for so long… I used it and works great. Thanks so much.

  • Paul

    Awesome… I’ve been looking for something like this for so long… I used it and works great. Thanks so much.

  • http://www.netexperienced.com Michael

    Hi,

    I applied the span version of your recommendation and it does as you suggest EXCEPT that the original (…) is still there (and not hyperlinked).

    Any suggestions?

  • http://www.netexperienced.com Michael

    Hi,

    I applied the span version of your recommendation and it does as you suggest EXCEPT that the original (…) is still there (and not hyperlinked).

    Any suggestions?

  • http://www.smallbusinessdoer.com Greg Lam

    Awesome! Worked great. Thanks!

  • http://www.smallbusinessdoer.com Greg Lam

    Awesome! Worked great. Thanks!

  • Atelnto

    Very Very Thank, Working Perfect

  • http://profiles.yahoo.com/u/Z4BBGFCHUXKB67VTXSGVLB6B5M Sufia

    Great work very useful. Thanks

  • http://www.ne-nerede.com Sesli Chat

    Thank you for opening this topic.

  • Pingback: Thumbnail or Nextgen gallery in excerpt « Michiel van Dijk

  • Brian

    Thank you so much worked great

  • http://www.fashionlieswithin.com Misskekebabyyy

    Thanks so much!

  • Pingback: An Introduction // jd french

  • Me

    Thank you!

  • aile chat

    Thank you. A very important issue. Is important for my research. Have a comprehensive site.

  • Guest

    Parse error: syntax error, unexpected ‘<' in /var/www/virtual/kujo.is/htdocs/wp-content/themes/application/functions.php on line 210 trololol

    • Rudd

      Trololol? Talk to the hand.

  • web site tasarımı

    okuduğum bir kitaptan etkilendim ve tasarım yaptım. çok başarılıydı diye düşünürken herkes beğendi. mutluyum :)