Created
March 8, 2017 07:40
-
-
Save sagarjadhav/fa780b0f3fa118db8a6b2844ed09e82f to your computer and use it in GitHub Desktop.
Limit the wp excerpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ! | |
* Function to trim excerpt | |
*/ | |
if ( !function_exists( 'limit_excerpt' ) ) { | |
function limit_excerpt( $lenght, $text ) { | |
$content = substr( $text, 0, $lenght ); | |
if ( strlen( $content ) < strlen( $text ) ) { | |
$content = $content . '…'; | |
} | |
echo $content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment