title: How to Prevent Wordpress from Stripping HTML Tags in Excerpt
body: <p>I am using wp_trim_words to trim some excerpts on my homepage. It's working fine except that it's stripping the HTML tags from the excerpts. I need to be able to make certain pieces of the excerpt bold (using <code>&lt;strong&gt;</code>). Following the instructions <a href="https://wordpress.stackexchange.com/questions/112503/how-to-include-html-in-excerpts">here</a>, I tried removing the wp_trim_words function and replacing it with a new one using the following code, which replaces <code>$text = wp_strip_all_tags( $text );</code> from the original WP function with <code>$text = strip_tags($text, '&lt;strong&gt;',);</code>. But this breaks the site. What am I doing wrong?</p>
  
  <pre><code>    // Remove Reverie Trim Words
  function remove_trim_words() {
      remove_filter('get_the_excerpt', 'wp_trim_words');
      add_filter('get_the_excerpt', 'oakwood_trim_words');
  }
  
  // Replace Reverie Trim Words
  function oakwood_trim_words( $text, $num_words = 55, $more = null ) {
      if ( null === $more )
          $more = __( '&amp;hellip;' );
      $original_text = $text;
      $text = strip_tags($text, '&lt;strong&gt;',);
      /* translators: If your word count is based on single characters (East Asian characters),
         enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
      if ( 'characters' == _x( 'words', 'word count: words or characters?' ) &amp;&amp; preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
          $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
          preg_match_all( '/./u', $text, $words_array );
          $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
          $sep = '';
      } else {
          $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
          $sep = ' ';
      }
      if ( count( $words_array ) &gt; $num_words ) {
          array_pop( $words_array );
          $text = implode( $sep, $words_array );
          $text = $text . $more;
      } else {
          $text = implode( $sep, $words_array );
      }
      /**
       * Filter the text content after words have been trimmed.
       *
       * @since 3.3.0
       *
       * @param string $text          The trimmed text.
       * @param int    $num_words     The number of words to trim the text to. Default 5.
       * @param string $more          An optional string to append to the end of the trimmed text, e.g. &amp;hellip;.
       * @param string $original_text The text before it was trimmed.
       */
      return apply_filters( 'oakwood_trim_words', $text, $num_words, $more, $original_text );
  }
  </code></pre>