WordPress issue.. how do I wrap stray text in P tags?
Example:
Before-
<div class = "content">
<img src = "hello.jpg"/>
<h1>Introduction</h1>
Hello! this is stray text that I want to wrap with p tags
Hello! This is another set of stray text
</div>
After-
<div class = "content">
<img src = "hello.jpg"/>
<h1>Introduction</h1>
<p>Hello! this is stray text that I want to wrap with p tags</p>
<p>Hello! This is another set of stray text</p>
</div>
WordPress uses a plugin called wpautop. This script automatically adds <p> </p> tags to new lines. In most cases, this is helpful. Sometimes, it can be a pain. In such a case you can use the Disable Autop Plugin.
You can manually control this by changing the core WordPress scripts. I suggest using a plugin.
Where is the stray text coming from? Is it being entered into the WordPress WYSIWYG editor? If so, it’ll automatically wrap the text in P tags if you have empty lines before and after the text.