Created
September 3, 2017 05:31
-
-
Save topleague/13d799f9f780bf4ca02046f7c87bbc03 to your computer and use it in GitHub Desktop.
Use HTML Tags in WordPress Excerpts
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
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { | |
$content = get_the_content($more_link_text, $stripteaser, $more_file); | |
// remove shortcode | |
$content = preg_replace("/\/", '', $content); | |
// short codes are applied | |
$content = apply_filters('the_content', $content); | |
$content = str_replace(']]>', ']]>', $content); | |
$content = strip_tags($content,' | |
,<b>,<strong>,<a>,<i>, | |
'); | |
if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { | |
$content = substr($content, 0, $espacio); | |
$content = $content; | |
echo " | |
"; | |
echo $content; | |
echo "..."; | |
echo " | |
"; | |
} | |
else { | |
echo " | |
"; | |
echo $content; | |
echo " | |
"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment