How to automatically add paragraph tags in WordPress

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!

Leave a Reply

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