How to automatically add paragraph tags in the Visual Editor

From my Googling, it appears as though the default behavior in Wordpress is to add paragraphs automatically, but in the HTML view, regardless of what style I choose in the Visual Editor's style drop-down (paragraph, for example), paragraph tags never appear. I also do not see wpautop() called anywhere in my theme (which I inherited from a now departed developer).

What can I do to set this straight? Adding p tags to everything is obviously not going to fly with the content editors.

Topic wp-autop Wordpress

Category Web


nl2br() can be used to add the line breaks again when using the filtered HTML again


I just struggled with this same issue and was about to loose my mind because I tried everything mentioned above and other ideas. It turned out that the client was using a Yootheme, and there is a tick box in the settings of that particular theme, which when clicked solved the issue immediately. Here's a link to the forum post: https://yootheme.com/support/question/4342

In other words, it could be a theme related issue.


Make sure you are using the_content for calling the post content and not something like get_the_content. WordPress wpautop filter is applied on the_content.


One solution is to install the TinyMCE Advanced plugin. In the plugin settings you have a option "Stop removing the <p> and <br /> tags when saving and show Them in the HTML editor".


The wpautop() filter changes the content view but not changes the view mode on the content editor.

Example: <?php the_content(); ?> displays the content normally. If you add remove_filter('the_content', 'wpautop'); the content is displayed without p tags.

In both cases, the content editor is displayed in the same manner


Paragraph tags are added upon display, not upon storage. The wpautop() function is added as a filter to the_content.

You won't ever see these added paragraph tags in either the visual or HTML editors.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.