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 using the following code to produce a wp_editor instance:

<?php if (version_compare($wp_version, "3.3") >= 0) { ?>
    <p><?php wp_editor(  $answer->post_content, 'answer', array( 'media_buttons' => true, 'wpautop' => true ) ); ?></p>
<?php } else { ?>
    <p><textarea name="answer" class="wp32"><?php echo esc_textarea( $answer->post_content ); ?></textarea></p>
<?php } ?>

Yet for some reason, the answer content isn't displaying with paragraphs.

The HTML for the question content is:

<div id="question-content"><p>I am somehow missing it.&nbsp;&nbsp; When I go to the “Knowledge Base” and click on “Tetras”</p>
<p>I get one page of tetra descriptions starting with the “A”s.</p>
<p>How do I get to the next page????</p>
</div>

But the HTML content for the answer is:

<div class="answer-content">
                Hi Jim,

The Tetras that you're seeing there are currently the only Tetras marked as being in that group!

Matt is working fervently to update the species database to our new website format, so at the moment, not every species is marked as being in the correct Knowledge Base groups.

Please bear with us!            </div>

EDIT: Printing out the answer content

    foreach ( $answers->posts as $answer ) {
        setup_postdata( $answer );
?>
    <div id="answer-<?php echo $answer->ID; ?>" class="answer">
        <?php the_answer_voting( $answer->ID ); ?>
        <div class="answer-body">
            <div class="answer-content">
                <?php echo get_the_content(); ?>
            </div>

            <div class="answer-meta">
                <?php the_qa_action_links( $answer->ID ); ?>
                <?php the_qa_author_box( $answer->ID ); ?>
            </div>
        </div>
    </div>
<?php

Any ideas?

Thanks in advance,

share|improve this question
    
You may have issues with your DOCTYPTE declaration also. I couldn't tell if the issues were caused by improperly displaying your content or if it's because the DOCTYPE declaration. You have improper html characters/entities that are either a product of the above issues, or may be in you Database code. A lot of "I'm not sure", but maybe it helps? –  Jeremy Jared May 6 '12 at 16:42
add comment

1 Answer 1

up vote 4 down vote accepted

Use the_content() not echo get_the_content();.

As you can see in wp-includes/default-filters.php wpautop is added for the filter 'the_content' which is called in the_content().

share|improve this answer
    
Tadaaaa! Thanks mate. I did wonder why the_content() hadn't been used. Implemented your solution and it works correctly. –  dunc May 6 '12 at 16:46
    
You could also use echo apply_filter( 'the_content', get_the_content() );. Not that it makes much sense, but you could mimic the core function :) –  kaiser May 6 '12 at 18:58
    
@kaiser you'd have to use apply_filters() now. Not sure if this was changed in a later version or not. –  mkprogramming Nov 4 '13 at 18:54
add comment

protected by kaiser Nov 4 '13 at 19:17

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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