This is a very quick guide that will explain how you can set the ‘Paste as text’ option to be active by default in the WordPress visual editor to prevent styles from being pasted into your content editor and ruining your layouts.
The function
I’ll cut right to the point, here is the function you will need to use to force the ‘Paste as text’ option to be active by default in the WordPress visual editor.
/* * Paste as plain text Default */ function wphelper_paste_as_text( $init ) { $init['paste_as_text'] = true; return $init; } add_filter('tiny_mce_before_init', 'wphelper_paste_as_text');
You can place the function above in your theme functions.php file or an MU plugin which would be a better option, this will now force the ‘Paste as text’ option to be on unless clicked in the visual editor. No longer will you accidentally paste formatted text into WordPress or have to worry about your clients doing so.
If you get stuck with adding this function to your site please leave a comment below or contact us.