更新 2018 / 09 / 19

入力画面のビジュアル・テキストエディタを増やす

固定ページ・投稿ページに入力画面を追加する。

SAMPLE

img

function.php

//meta boxを追加
//add_action( 'admin_init', 'custom_editor_input_meta_box' );
//edit_form_after_editor で追加
add_action( 'edit_form_after_editor', 'custom_editor_input' );
add_action( 'save_post', '_metabox_save' );
 
function custom_editor_input_meta_box() {
 
    add_meta_box( 'extend_edit_field', 'extend edit field', 'custom_editor_input', 'post', 'normal', 'high' );
}
 
function custom_editor_input() {
    global $post;
    $args= array(
                'textarea_rows'=> 6,
                'teeny'=> false,
                'quicktags'=> true
            );
    echo '

Extend Edit Field

'; echo ''; $content= get_post_meta($post->ID,'_my_extend_editor',true); wp_editor( $content, 'my_extend_editor',$args ); } function _metabox_save($post_id) { global $post; $extend_edit_field_noncename = filter_input ( INPUT_POST , 'extend_edit_field_noncename' ); if ( isset( $post->ID ) && !wp_verify_nonce( $extend_edit_field_noncename , plugin_basename(__FILE__) )) { return $post->ID; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id; $custom_css = filter_input ( INPUT_POST , 'my_extend_editor' ); if( isset( $custom_css ) && !is_null( $custom_css ) ) { update_post_meta($post_id, '_my_extend_editor', $custom_css); } }

single.php

<?php echo get_post_meta($post->ID,'_my_extend_editor',true);?>