22Jan

Stop WordPress removing tags – without plugins

WordPress editor can be really annoying, you probably experienced that. You can add a small function to your function.php file and voilà!


// STOP WORDPRESS REMOVING TAGS
function tags_tinymce_fix( $init )
{
  // html elements being stripped
  $init['extended_valid_elements'] = 'div[*],article[*]';
  // don't remove line breaks
  $init['remove_linebreaks'] = false;
  // convert newline characters to BR
  $init['convert_newlines_to_brs'] = true;
  // don't remove redundant BR
  $init['remove_redundant_brs'] = false;
  // pass back to wordpress
  return $init;
}
add_filter('tiny_mce_before_init', 'tags_tinymce_fix');
Subscribe
Notify of

4 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Jana
6 years ago

Thank you so much!

[…] As I said, I have added the TinyMCE Advanced editor, I have also added different code to functions.php to solve the issue similar to: what can be seen here. […]

dallas720
5 years ago

What about the