web_dor_the_excerpt_max_charlength

The Business Responsive web dor the excerpt max charlength function.

Description

web_dor_the_excerpt_max_charlength( $charlength ); 

Parameters (1)

0. $charlength
The charlength.

Usage

  1. if ( !function_exists( 'web_dor_the_excerpt_max_charlength' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4. // The charlength. 
  5. $charlength = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = web_dor_the_excerpt_max_charlength($charlength); 
  9.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function web_dor_the_excerpt_max_charlength($charlength) { 
  2. $excerpt = get_the_excerpt(); 
  3. $charlength++; 
  4.  
  5. if ( mb_strlen( $excerpt ) > $charlength ) { 
  6. $subex = mb_substr( $excerpt, 0, $charlength - 5 ); 
  7. $exwords = explode( ' ', $subex ); 
  8. $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); 
  9. if ( $excut < 0 ) { 
  10. echo mb_substr( $subex, 0, $excut ).'...'; 
  11. } else { 
  12. echo $subex.'...'; 
  13.  
  14. } else { 
  15. echo $excerpt;