carasmo
3/24/2017 - 3:44 PM

Allowed Html in Content Limit and Balance tags so that there are not open tags messing up your site.

Allowed Html in Content Limit and Balance tags so that there are not open tags messing up your site.

<?php
//don't add again 


/**
 *
 * Allowed html in get_the_content_limit
 *
 */
function yourprefix_allowed_content_limit_tags() {
	return '<strong>,<em>,<i>,<ul>,<ol>,<li>,<a>'; 
}
add_filter( 'get_the_content_limit_allowedtags', 'yourprefix_allowed_content_limit_tags' );


/**  
 * 
 * Close open tags in content limit excerpts
 * force_balance_tags();
 * 
 */
function yourprefix_balance_tags_content_limit( $content ) {
	
	$content = force_balance_tags( html_entity_decode( wp_trim_words( htmlentities( $content ) ) ) );
		
	return $content . '<p><a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a></p>';
	
}
add_filter( 'the_content_limit', 'yourprefix_balance_tags_content_limit' );