Last active
October 24, 2017 19:08
-
-
Save igorveremsky/375a7bc21f5631b76d2abeedec84b22f to your computer and use it in GitHub Desktop.
Custom Excerpt for Wordpress
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 | |
/** | |
* Excerpt content | |
*/ | |
function iv_excerpt($excerpt_length, $added) | |
{ | |
$text = apply_filters( 'the_excerpt', get_the_excerpt() ); | |
$text = preg_replace('/\[.+\]/', '', $text ); | |
$chars_text = strlen($text); | |
$text = $text." "; | |
$text = substr($text,0,$excerpt_length); | |
$text = substr($text,0,strrpos($text,' ')); | |
$text = $text.$added; | |
$text = apply_filters('the_content', $text); | |
$text = str_replace(array('[…]','[...]', '<p>', '</p>'), '', $text ); | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment