Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static function get_excerpt($post, $ln, $output = true){
- if (!empty($post->post_excerpt)) {
- if (strlen(strip_tags(strip_shortcodes($post->post_excerpt))) > $ln) {
- $excerpt = mb_substr(strip_tags(strip_shortcodes($post->post_excerpt)), 0, $ln) . '<a href="' . get_permalink($post->ID) . '">... ['.__('read more','cosmotheme').']</a>';
- } else {
- $excerpt = strip_tags(strip_shortcodes($post->post_excerpt));
- }
- } else {
- if (strlen(strip_tags(strip_shortcodes($post->post_content))) > $ln) {
- $excerpt = mb_substr(strip_tags(strip_shortcodes($post->post_content)), 0, $ln) . '<a href="' . get_permalink($post->ID) . '">... ['.__('read more','cosmotheme').']</a>';
- } else {
- $excerpt = strip_tags(strip_shortcodes($post->post_content));
- }
- }
- if ($output == true) {
- echo $excerpt;
- }else{
- return $excerpt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement