DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

By default, WordPress automatically add paragraph tags to the content and the excerpt, using the wpautop() function. If you need to automatically add some <p> tags to any text, you can use the function as shown in today’s example.

In order to add paragraph tags to any text, simply use the wpautop() function, as shown below:

$my_text = 'Lorem ipsum dolor sit amet
consectetur adipiscing elit. 
Nulla pretium libero eget gravida rutrum.';

echo wpautop( $my_text );

Thanks to Daniel Pataki for the tip!

Tags

Leave a Comment

Your email address will not be published. Required fields are marked *