3

What's the simplest way to add a second HTML editor to the post/page admin and show the content in a template?

What I need is something like a custom field that supports html, but I don't need the options to name the field. And I don't need a visual editor like tinyMCE; just html will do.

What I'm thinking of is simply a small text-editor box that sits under the main visual/html editor and shows the resulting html in a template via <?php if ( function_exists('my_extra_editor_content') ) ... with the text/html in a styleable div.

Plugins like http://wordpress.org/extend/plugins/custom-field-template/ and http://wordpress.org/extend/plugins/developers-custom-fields/ offer too much in terms of functions and choices.

3

I use Bill Erickson's custom meta boxes or plugin like Secondary HTML Content (probably the easiest solution)

  • Thanks, I tried both and both work well for different needs; Custom Meta Boxes and Fields for complex uses, and the Secodnary HTML Content for simple sites. But I now use CMB&F for everything. – markratledge Jul 16 '14 at 16:15
2

I dont know if this will help but any Custom Field input will support html. I use html there all the time for headings and custom text in posts and pages.

0

Have you tried a textarea in a meta box? Meta boxes are more user friendly.

About your requirement, it sounds like just a textarea will do. Please be aware that even full tinyMce based editors are possible using existing WordPress libraries.

0

For future travelers, the custom metaboxes are not a good idea for adding a second editor in pages. You should use wp_editor function inside the edit_page_form action so the form can be displayed. (You should use edit_form_advanced action for custom post types)

Then you can use the save_post and get the value of the editor from $_POST object. Here's an example:

add_action( 'edit_page_form', 'se24801_add_second_editor' );
function se24801_add_second_editor() {
    echo '<h2>Second Content </h2>'; 
    $content = get_post_meta( $post->ID, 'second_content', true );
    wp_editor(
        $content,
        'second_content',
        array(
            'media_buttons' =>  true,
        )
    );    
} 

add_action( 'save_post', 'se24801_save_second_content' );
function se24801_save_second_content( $post_id ) {
    if(isset( $_POST['second_content'] ) ) {
        update_post_meta( $post_id, 'second_content', $_POST['second_content'] );
    }  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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