Simplest way to add a second html editor to the postpage admin?

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

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 / and / offer too much in terms of functions and choices.

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/extend/plugins/custom-field-template/ and http://wordpress/extend/plugins/developers-custom-fields/ offer too much in terms of functions and choices.

Share Improve this question edited Apr 3, 2015 at 11:57 Brad Dalton 6,9652 gold badges36 silver badges47 bronze badges asked Aug 3, 2011 at 13:42 markratledgemarkratledge 8,7356 gold badges40 silver badges62 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 3

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

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.

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'] );
    }  
}

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.

Update from 2020. This is now extremely easily achievable with the Advanced Custom Fields plugin and using its provided function call the_field('field_ref') to insert in the page.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742351821a4427670.html

相关推荐

  • Simplest way to add a second html editor to the postpage admin?

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

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信