Matt
Matt

Reputation: 22911

Wrap stray text in <p> tags

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>

Upvotes: 2

Views: 2245

Answers (2)

Sid Kathirvel
Sid Kathirvel

Reputation: 858

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.

Upvotes: 3

Jeff
Jeff

Reputation: 21892

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.

Upvotes: 0

Related Questions