Created
January 21, 2017 22:35
-
-
Save tayvano/2b8693f147df1a6d4c8807e7fdbd0ff0 to your computer and use it in GitHub Desktop.
This file contains 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
function limit_char($limit, $source=null) { | |
global $post; | |
($source) ? '<p>'.$source.'</p>' : $source = '<p>'.get_the_excerpt().'</p>'; | |
$read_more = '... <a href="'. get_permalink($post->ID) . '" class="more-link" title="Read '.get_the_title($post->ID).'">Read more</a>'; | |
$limited = strlen($source) > $limit ? substr($source,0,strpos($source,' ',$limit)) . $read_more : $source; | |
echo $limited; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment