Skip to main content
2 of 3
added 29 characters in body

Add hook after content without formatting

I want to add a table after the_content with a hook, but it's adding <p> tags in certain areas. This is a plugin, I don't want to remove <p> tags from all the_content, just the table I'm trying to add.

Here's an example, but my table is bigger and inside it's adding p tags in different spots.

function addTable( $content ) {
  $table = '<table><tbody><tr><td>Example html here</td></tr></tbody></table>';

  $content .= $table;

  return $content;
}

add_filter( 'the_content', addTable, 20 );

Someone asked this in 2012, no answer but I'm trying to do the same thing: Adding a form at the end of the content

I do not want to remove <p> tags from a theme's entire blog post, only the content I am appending. In this case, I'm appending a table.

Is there a way to disable the formatting for only the content I'm appending? Otherwise, how is it possible in WordPress to attach a form or table to a post with hooks without it adding formatting?