I have a get_the_content() Wordpress code as you can see below. I want to force the code to do the following:
- Don't display empty tags as nbsp; (works now)
- Display only a limited amount of words (don't know how)
I added this code to my home.php:
<?php
$content = get_the_content('Read more');
$content = str_replace(' '," ", get_the_content());
$content = preg_replace( '/\s+/', ' ', $content );
echo $content;
?>
It works, but i want to display only a limited amount of words now. All the solutions as $char_limit and wp_trim_words() are not the solutions i am looking for, because they are mess up the blog posts.
What can i do?