Posted By

maxxscho on 10/13/11


Tagged


Versions (?)

Wordpress Excerpt Dynamic Length


 / Published in: PHP
 

  1. function ms_rp_excerpt($limit) {
  2. $excerpt = explode(' ', get_the_excerpt(), $limit);
  3. if (count($excerpt) >= $limit) {
  4. array_pop($excerpt);
  5. $excerpt = implode(' ', $excerpt).'...';
  6. }
  7. else {
  8. $excerpt = implode(' ', $excerpt);
  9. }
  10. $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt);
  11. return $excerpt;
  12. }

Report this snippet  

You need to login to post a comment.