Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm setting up a blog that I'm trying to integrate the posts of into old site pages. The

$id = $_GET['article_id'];
$post = get_post($id);
setup_postdata($post);
echo $post->post_content;

However, when I echo the blog post from $post->post_content, it seems that the html has been stripped out. The lines all run together. There are line breaks in the source, but there are no html <BR>s or <p>s. However, the post looks fine when I view it through the actual WordPress page.

I have to use <pre> to get it to display properly, but then on the page, lines don't wrap and it defaults to that typewriter font.

What am I doing wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Post content, stored in database, is not equal to what gets displayed. It should be displayed with template tag function or at least run through the_content filter. Try:

the_content();

Or:

echo apply_filters( 'the_content', $post->post_content );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.