By default WordPress adds <p> tags at runtime, so the editor is usually set up to strip them out. But sometimes you might need to use an editor where these tags aren’t stripped out, for example writing content for a newsletter that needs to have these tags in. And you might not want to change the default behaviour of the entire site for that!
You can instead simply summon an editor and add the wpautop field as false, something like this:
wp_editor($content, 'field-editor-name', [
'name' => $name,
'class' => 'wp-editor-container',
'media_buttons' => false,
'wpautop' => false,
]);
This gets rendered like this:
See all the arguments you can use here: https://developer.wordpress.org/reference/classes/_wp_editors/parse_settings/
What is wpautop?
A group of regex replaces used to identify text formatted with newlines and replace double line breaks with HTML paragraph tags.
Comments