title: why does the_excerpt() add <p> tags to table data when i do not allow table tags in the excerpt?
body: <p>I am developing a Wordpress theme. I am trying not to allow any data from tables to show in the automatic post excerpt on the homepage of my blog. I am however allowing <code>&lt;p&gt;</code> tags. The data in the table in the post page does not have <code>&lt;p&gt;</code> tags but are instead in <code>&lt;td&gt;</code> tags. When I view the excerpt it produces all of the table data under one big <code>&lt;p&gt;</code> tag which is visible. How can I prevent this from happening?</p>
  
  <p>If i put in a manual excerpt it overides what would be automatically shown so i have no problems with that method. But it feels like a workaround whereas i would like to fix the actual problem. </p>
  
  <p>On a side note, if I allow table tags and all of its children in the excerpt it completely breaks the lower half of my webpage which uses CSS Grid, putting the sidebar, which is in the 3rd column of the grid, inside of it, meaning there is now a total of only 2 columns. Its very strange.</p>
  
  <p>So i am mainly seeking to display no table data in the excerpt, but would be interested to know if anyone has any ideas about the second problem, although not necessary.</p>
  
  <p>If i need to produce the code as an example let me know which code as i feel i would need to produce a lot of it and the fact it would only work in wordpress means it won't work here. </p>
  
  <p>EDIT: Adding code:</p>
  
  <p>PHP function
      //allow html in excerpts</p>
  
  <pre><code>function new_wp_trim_excerpt($text) {
      $raw_excerpt = $text;
      if ( '' == $text ) {
        $text = get_the_content('');
  
        $text = strip_shortcodes( $text );
  
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]&gt;', ']]&gt;', $text);
  
        $text = strip_tags($text, '&lt;blockquote&gt;&lt;q&gt;&lt;cite&gt;&lt;td&gt;&lt;a&gt;&lt;p&gt;&lt;br&gt;&lt;ol&gt;&lt;ul&gt; 
        &lt;li&gt;');
        $excerpt_length = apply_filters('excerpt_length', 55);
  
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $words = preg_split('/[\n|\r|\t|\s]/', $text, $excerpt_length + 1, 
         PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE );
      if ( count($words) &gt; $excerpt_length ) {
          array_pop($words);
          $text = implode(' ', $words);
          $text = $text . $excerpt_more;
      } else {
          $text = implode(' ', $words);
      }
  }
  return apply_filters('new_wp_trim_excerpt', $text, $raw_excerpt);
  
  }
  remove_filter('get_the_excerpt', 'wp_trim_excerpt');
  add_filter('get_the_excerpt', 'new_wp_trim_excerpt');
  </code></pre>
  
  <p>PHP calling the excerpt:</p>
  
  <pre><code>&lt;div class="latest-news"&gt;
              &lt;h1&gt;Latest News&lt;/h1&gt;
          &lt;/div&gt;
  
              &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 
  ?&gt;
  
                  &lt;div class="home-posts-content"&gt;
                     &lt;?php the_title('&lt;h2 class="loop-headers"&gt;&lt;a href="' . 
  get_permalink( get_the_ID() ) . '"&gt;', '&lt;/a&gt;&lt;/h2&gt;'); ?&gt;
                     &lt;div class="loop-post-meta"&gt;
                          &lt;p&gt;&lt;?php echo get_the_date(); ?&gt;&lt;/p&gt;
                          &lt;p&gt;Posted by &lt;?php the_author(); ?&gt;&lt;/p&gt;
                      &lt;/div&gt;
                     &lt;div class="post-content"&gt;
                      &lt;?php if ( has_post_thumbnail()) : ?&gt;
                      &lt;a href="&lt;?php the_permalink(); ?&gt;" alt="&lt;?php 
   the_title_attribute(); ?&gt;"&gt;
                      &lt;?php the_post_thumbnail(); ?&gt;
                      &lt;/a&gt;
                      &lt;?php endif; ?&gt;
  
                      &lt;?php echo get_the_excerpt(); ?&gt;
                  &lt;/div&gt;&lt;!--end .post-content--&gt;
                 &lt;/div&gt;&lt;!--end .home-post-content--&gt;
              &lt;?php 
  
              endwhile; 
  
              else :
  
                  _e( 'There are currently no posts available.', 'textdomain' 
  );
  
              endif;
  
  
              ?&gt;
          &lt;div class="loop-pagination"&gt;
              &lt;div class="prev"&gt;
                  &lt;?php previous_posts_link() ?&gt;
              &lt;/div&gt;
              &lt;div class="next"&gt;
                  &lt;?php next_posts_link(); ?&gt;
              &lt;/div&gt;
              &lt;/div&gt;
      &lt;/div&gt;&lt;!--end .post-container--&gt;
  </code></pre>