News Update :
Home » » Excerpt limit with custom words without plug-ins

Excerpt limit with custom words without plug-ins

By: Unknown on Thursday, 12 February 2015 | 06:09

If you want to manage throughout the website:

unction custom_excerpt_length( $length ) {
return 28;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

 








 Or in each case:

in function.php:

<?php
function string_limit_words($string, $word_limit)
{
  $words = explode(' ', $string, ($word_limit + 1));
  if(count($words) > $word_limit)
  array_pop($words);
  return implode(' ', $words);
}
?>


Where you want to display the excerpt:

p><?php
  $excerpt = get_the_excerpt();
  echo string_limit_words($excerpt,25);
?></p>
 
Contact Us | Privacy policy | Term of use | Advertise with Us | Site map
Copyright © 2011. Blogging Brain . All Rights Reserved.
Design Template by Blogging Brain | | Powered by Blogger