<p></p> missing with wp_editor( get_option() );

I am trying to add some options to my theme and I added a wysiwyg textarea and the value of this textarea will go to the option table (wp-options).

So here is the code I used:

Read More
$settings = array(
  'textarea_name' => 'options[content]',
  'quicktags' => true,
  'tinymce'=> true,
);
wp_editor( get_option('content','default_value'), 'content', $settings );

This work pretty fine but this apparently remove all <p> tags from the content and i have absolutely no idea why..

For example when i wrote something like this:

Level 1 title
  Level 2 title
    a paragraph
    another paragraph

this is the code sent to the db called ‘content’:

<h1>Level 1 title</h1>
  <h2>Level 2 title</h2>
    a paragraph another paragraph

instead of this:

<h1>Level 1 title</h1>
  <h2>Level 2 title</h2>
    <p>a paragraph</p>
    <p>another paragraph</p>

Do you have any idea what i can do get unchanged value with all tags?

ps: when i add <p> tags manually to the text side, it works until I go back to the visual side and re-save.

Thanks for helping

Related posts

Leave a Reply

2 comments

  1. I know this is an old question that has had an accepted answer for some time but the answer didn’t work for me, so I am adding the solution that did in case it helps anyone else.

    I should explain that my problem was slightly different in that it was in the admin settings page of a plug-in, rather than a theme, but the principle should be the same. That is, in both cases the output from wp_editor needs to be stored in an option and later retrieved with paragraph tags intact.

    The solution for me is based on the Codex description of the wp_editor and involves adding wpautop as an argument to the wp_editor call. Somewhat counter-intuitively, it needs to be set to false in order for paragraph tags to be added automatically. However, the original call to wpautop is also required to include the paragraph tags in the admin page.

    $args = array(
      'wpautop' => false
    );
    wp_editor( wpautop( $content ), $editor_id, $args );
    
  2. Use wpautop function on your content to add <p> tags around your paragraphs.

    wp_editor( wpautop(get_option('content','default_value')), 'content', $settings );