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.

72 responses to “Tip: How to change the default WordPress excerpt”

  1. Natalie Wi Avatar
    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?

    1. Thad Avatar

      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.

  2. Natalie Wi Avatar
    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?

    1. Thad Avatar

      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.

  3. Natalie Wi Avatar

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

  4. Natalie Wi Avatar

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

  5. Effective Web Design Avatar

    Very useful tips, thank you.

  6. Effective Web Design Avatar

    Very useful tips, thank you.

  7. Belosic - Reno Graphic Design Avatar

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

  8. Belosic - Reno Graphic Design Avatar

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

  9. Eli Avatar
    Eli

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

  10. Eli Avatar
    Eli

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

  11. Custom Logo Design Avatar

    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..

  12. Custom Logo Design Avatar

    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..

  13. JamesSpratt.org Avatar

    Nice one, works a dream. Thank you.

  14. JamesSpratt.org Avatar

    Nice one, works a dream. Thank you.

  15. begamo Avatar

    This is simple but useful tips, thanks.

  16. begamo Avatar

    This is simple but useful tips, thanks.

  17. ALAN Avatar

    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

  18. ALAN Avatar

    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

  19. Kate Avatar

    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

  20. Kate Avatar

    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

  21. 4oo2.com Avatar

    Thank you for all the info

  22. 4oo2.com Avatar

    Thank you for all the info

  23. 4oo2.com Avatar

    Thanks for the nice information

  24. 4oo2.com Avatar

    Thanks for the nice information

  25. education Avatar

    thanks for your article

    it is a nice blog

  26. education Avatar

    thanks for your article

    it is a nice blog

  27. Lyndon Avatar

    This is very detailed. Thanks for teh screenshots.

  28. Lyndon Avatar

    This is very detailed. Thanks for teh screenshots.

  29. tabela Avatar

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

  30. tabela Avatar

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

  31. Jacques | Web Design Avatar

    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)!!!

  32. Jacques | Web Design Avatar

    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)!!!

  33. Submit My Article Avatar

    Wow, that was easy. thank you.

  34. Submit My Article Avatar

    Wow, that was easy. thank you.

  35. Dave Avatar

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

  36. Dave Avatar

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

  37. Craig Avatar

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

  38. Craig Avatar

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

  39. richard p walton Avatar

    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!

  40. richard p walton Avatar

    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!

  41. Seth Avatar

    Thank you! That was an excellent tip.

  42. Seth Avatar

    Thank you! That was an excellent tip.

  43. MetacomCreative Avatar

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

  44. MetacomCreative Avatar

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

  45. Dizi izle Avatar

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

  46. Dizi izle Avatar

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

  47. Oyunlar Avatar

    i will try. thnx

  48. Oyunlar Avatar

    i will try. thnx

  49. telefon dinleme Avatar

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

  50. telefon dinleme Avatar

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

  51. Dan Wiersema Avatar

    Extremely helpful, thanks so much!

  52. Dan Wiersema Avatar

    Extremely helpful, thanks so much!

  53. Deo Avatar

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

  54. Deo Avatar

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

  55. Paul Avatar
    Paul

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

  56. Paul Avatar
    Paul

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

  57. Michael Avatar

    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?

  58. Michael Avatar

    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?

  59. Greg Lam Avatar

    Awesome! Worked great. Thanks!

  60. Greg Lam Avatar

    Awesome! Worked great. Thanks!

  61. Atelnto Avatar
    Atelnto

    Very Very Thank, Working Perfect

  62. Sufia Avatar

    Great work very useful. Thanks

  63. Sesli Chat Avatar

    Thank you for opening this topic.

  64. Brian Avatar
    Brian

    Thank you so much worked great

  65. Me Avatar
    Me

    Thank you!

  66. aile chat Avatar
    aile chat

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

  67. Guest Avatar
    Guest

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

    1. Rudd Avatar
      Rudd

      Trololol? Talk to the hand.

  68. web site tasarımı Avatar
    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 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *