I have been using this code for a long time :
$temp_arr_content = explode(
" ",
substr(
strip_tags(
get_the_content()
),
0,
720
)
);
$temp_arr_content[count( $temp_arr_content ) - 1] = "";
$display_arr_content = implode( " ", $temp_arr_content );
echo $display_arr_content;
if( strlen( strip_tags( get_the_content() ) ) > 0 )
echo "...";
To limit my content to 720 characters and strip html from it
However, today I used it again in my new theme but I noticed that it also outputs the HTML codes (the HTML code is not working, but shows up in the content) .
I have also used this code in my theme :
$excerpt = get_the_excerpt();
echo string_limit_words( $excerpt, 55 );
and this code on my Function.php :
function string_limit_words( $string, $word_limit ) {
$words = explode( ' ', $string, ( $word_limit + 1 ) );
if( count( $words ) > $word_limit )
array_pop( $words );
return implode( ' ', $words );
}
to limit words and strip HTML , however, when I change 55 to 150 the code does not work and it still shows 55 words.
can someone please help me resolve this issue ?
thanks