Add paragraph tags to post content in wordpress?

I’m getting some pages with the get_pages function and echoing the page content like: $page->post_content, but contrary to the_content(), this way wordpress wont add p tags automatically, is there any way to add them here?

Thanks in advance

Related posts

Leave a Reply

4 comments

  1. Jose Carlos’ answer is actually the better approach. Out of the box, ‘the_content’ filter is loaded with the following actions:

    • capital_P_dangit
    • wptexturize
    • convert_smilies
    • convert_chars
    • wpautop
    • shortcode_unautop
    • prepend_attachment

    So you can see that there’s a lot more intelligence behind this filter. If you’re positive that you don’t need the other stuff (are you 100% sure you’ll never have shortcode or smilies in your text?) then go ahead and use wpautop(), but you may regret it later on.

  2. This might be what you’re looking for, isn’t it?

    <?php
    
    // Get WordPress pages
    $wp_pages = get_pages();
    
    foreach ($wp_pages as $wp_page)
    {
        echo '<p>';
        echo $wp_page->post_content;
        echo '</p>';
    }