Issues with the excerpt (wordcount/HTML/images)

Answer on my own question (without using a plugin and choosing a middle way) for what we want to achieve.

Because the template has also a code starting with:

if ( has_post_thumbnail() && ( $post->post_type == 'post' ) )

we have taken that part of code away. (we won’t used it in postings/pages, therefore)

Following part of code (below) in the template allows us:

  • use of the feature image option, which will show that image on the excerpt only
  • character count (not word count but works), which is the, as mentioned, middle way
  • showing the permalink (read more..)
  • use of <p> <br> <pre> and some more

Maybe it is not flawless but seems to work great although (maybe) not common. A part of that code is found here second excerpt.

If someone thinks it could trigger some error or would handle the search option in a nasty way, I invite you to comment and help us to make it in that case “foolproof”.
Thank you.

if (is_home() ||is_front_page() || is_archive() || is_search() || is_category()){
the_post_thumbnail('thumbnail', array('class' => 'excerpt_img '));  
echo substr( get_the_excerpt(), 0, strrpos( substr( get_the_excerpt(), 0, 500),''));
echo '<a class="read-more" href="'. get_permalink( get_the_ID() ).'"> .... Read More</a>';

Note:

For whatever reason the plugin as mentioned by markcbain did not work for us anyway!

Btw we don’t use code-snippets in a theme functions.php we use mu-pugins if code is needed for more then just one theme and/or a plugin “code-snippets” for other usesfull code.