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');

4
Leave a Reply

3 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
  Subscribe  
newest oldest
Notify of
Jana

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

What about the