0

I'm embedding the_editor on a admin page:

<?php the_editor(get_option('options_name'),'options_name'); ?>  

And everything works fine, at least in back-end:

TinyMce

BUT on the front-end side I'm always getting inline output, there are no automatic paragraphs, breaks etc. They're just not being created. When I type them manually using HTML tags - it works.

enter image description here

Any ideas what's wrong?

Here's the full code so you will be able to copy&paste everything and check for your own. Does it work for you guys>

Admin page:

<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>
    <div id="poststuff">
        <div id="post-body">
            <div id="post-body-content">
                <div id="postrichdiv" class="postarea">
                    <?php the_editor(get_option('custom_editor_test'),'custom_editor_test'); ?>
                </div>
            </div>
        </div>
    </div>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="custom_editor_test" />
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>

Front-end (do_shortcode part is optional, by the way shortcodes are being rendered just fine in my case):

<?php echo do_shortcode(get_option('custom_editor_test')); ?>     
0

2 Answers 2

1

Try running wpautop on output of the text like so:

<?php echo do_shortcode( wpautop( get_option( 'custom_editor_test' ) ); ?>
1

Jared's answer will get you the auto paragraph tags. But a more complete solution might be to run the the_content filter on your text with apply_filters. This will run the following functions on your text: wptexturize, convert_smilies, convert_chars, wpautop, shortcode_unautop, prepend_attachment.

I believe it'll also run do_shortcodes for you. So that'll simplify things a lot.

<?php

    $content = get_option('custom_editor_test');
    echo apply_filters( 'the_content', $content );

?>

You might be able to do the get_option call right inside the apply_filter call. I didn't try it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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