Reputation: 4058
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
Upvotes: 7
Views: 16763
Reputation: 249
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>';
}
Upvotes: -4
Reputation: 20111
Jose Carlos' answer is actually the better approach. Out of the box, 'the_content' filter is loaded with the following actions:
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.
Upvotes: 3
Reputation: 1015
You should use <?php echo apply_filters('the_content', $page->post_content); ?>
Upvotes: 27