Wordpress: Limit The Excerpt’s Word Count


/ Published in: PHP
Save to your folder(s)

One thing that can go wrong in WordPress magazine themes is when users include too many words before the more tag.


Copy this code and paste it in your HTML
  1. /**
  2. * Limit The Excerpt’s Word Count
  3. *
  4. * http://www.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/
  5. *
  6. *
  7. */
  8. function ilc_excerpt_length( $length ){
  9. return 10;
  10. }
  11. add_filter('excerpt_length', 'ilc_excerpt_length');

URL: http://www.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.