Modifying your post excerpts

March 15, 2011 – 9:14 am |

This is my personal favorite way of modifying excerpts, I found all this information on the WordPress codex excerpts page.

I think that the WordPress excerpt is a little bit short so the code below will extend it to 120 words. Also, by default WordPress only shows the [...] at the end of the excerpt, which doesn’t help my readers when they get to the end of the text.

  1. /**
  2.  * The Read More link after the post excerpt
  3.  */
  4. function new_excerpt_more($more) {
  5.        global $post;
  6.  return '… <a href="'. get_permalink($post->ID) . '">&raquo; Read More</a>';
  7. }
  8. add_filter('excerpt_more', 'new_excerpt_more');
  9.  
  10. /**
  11.  * This changes the length of the excerpt to 120 words
  12.  */
  13. function new_excerpt_length($length) {
  14.  return 120;
  15. }
  16. add_filter('excerpt_length', 'new_excerpt_length');
pixel Modifying your post excerpts

Tagged: , , , , ,