Advertisement
nlozovan

Untitled

Apr 9th, 2014
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. static function get_excerpt($post, $ln, $output = true){
  2. if (!empty($post->post_excerpt)) {
  3. if (strlen(strip_tags(strip_shortcodes($post->post_excerpt))) > $ln) {
  4. $excerpt = mb_substr(strip_tags(strip_shortcodes($post->post_excerpt)), 0, $ln) . '<a href="' . get_permalink($post->ID) . '">... ['.__('read more','cosmotheme').']</a>';
  5. } else {
  6. $excerpt = strip_tags(strip_shortcodes($post->post_excerpt));
  7. }
  8. } else {
  9. if (strlen(strip_tags(strip_shortcodes($post->post_content))) > $ln) {
  10. $excerpt = mb_substr(strip_tags(strip_shortcodes($post->post_content)), 0, $ln) . '<a href="' . get_permalink($post->ID) . '">... ['.__('read more','cosmotheme').']</a>';
  11. } else {
  12. $excerpt = strip_tags(strip_shortcodes($post->post_content));
  13. }
  14. }
  15. if ($output == true) {
  16. echo $excerpt;
  17. }else{
  18. return $excerpt;
  19. }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement