Php WP_编辑器不在自定义元框div中。如何将WP_编辑器保留在div中?

Php WP_编辑器不在自定义元框div中。如何将WP_编辑器保留在div中?,php,wordpress,wp-editor,Php,Wordpress,Wp Editor,我的自定义帖子类型具有自定义元框,其中包含输入字段和wp\u编辑器,位于代码下方: <div class="inside"> <div> <label>Title</label> <input type="text" name="title[]"> </div> <div> <label>Type</label>

我的自定义帖子类型具有自定义元框,其中包含
输入
字段和
wp\u编辑器
,位于代码下方:

<div class="inside">
    <div>
        <label>Title</label>
        <input type="text" name="title[]">
    </div>
    <div>
        <label>Type</label>
        <input type="text" name="type[]">
    </div>
    <div>
        <label>Content</label>
        '.wp_editor($content, 'text', array(
        'wpautop' => true,
        'media_buttons' => false,
        'textarea_rows' => 5
        )
        ).'
    </div>
</div>

标题
类型
内容
.wp_编辑器($content,'text',数组(
“wpautop”=>true,
“媒体按钮”=>错误,
“textarea_rows”=>5
)
).'
wp\u编辑器
位于
内部
分区的顶部和外部

如何在内容标签下方的
.inside
div中使用
wp\u编辑器?

add\u操作('add\u meta\u box','global\u banner\u setting\u meta\u box');
add_action( 'add_meta_boxes', 'global_banner_setting_meta_box' );
function global_banner_setting_meta_box() {
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;

    add_meta_box(
        'banner_setting_data',
        __( 'Banner Setting', 'launchpm' ),
        'render_metabox',
        'page',
        'advanced',
        'default'
    );
}
function render_metabox( $post ) {

    field_generator( $post );
}    
function field_generator( $post ) {
    wp_nonce_field( 'banner_nonce_action', 'banner_nonce' );

    $banner_title_data = get_post_meta($post->ID,'banner_title_data_',true);
    $banner_description_data = get_post_meta($post->ID,'banner_description_data_',true);

    if(empty($banner_title_data)){$banner_title_data = '';}
    if(empty($banner_description_data)){$banner_description_data = '';}

    $banner_html_code = '<div id="postcustomstuff">';
    $banner_html_code .='<table class="form-table">';
    $banner_html_code .='<tr>';
    $banner_html_code .='<td><label style="display:block; font-weight:600; margin:0 8px;" for="banner_title_data" class="banner_title_label">' . __( 'Banner Title', 'launchpm' ) . '</label><input type="text" id="banner_title_data" name="banner_title_data" class="banner_title_data_field" placeholder="' . esc_attr__( '', 'launchpm' ) . '" value="' . esc_attr__( $banner_title_data ) . '"></td>';
    $banner_html_code .='</tr>';
    $banner_html_code .='<tr>';
    $banner_html_code .='<td><label style="display:block; font-weight:600; margin:0 8px;" for="banner_description_data" class=banner_description_data_label">' . __( 'Banner Description', 'launchpm' ) . '</label>
    <textarea id="banner_description_data" class="textarea banner_description_data_field" name="banner_description_data" placeholder="' . esc_attr__( '', 'launchpm' ) . '" rows="8">' . esc_attr__( $banner_description_data ) . '</textarea></td>
    ';
    $banner_html_code .='</tr>';
    $banner_html_code .='</table>';
    $banner_html_code .='</div>';
    echo $banner_html_code;
}
add_action( 'save_post','save_metabox_banner_data', 10, 2);
function save_metabox_banner_data($post_id, $post)
{
    $nonce_name   = $_POST['banner_nonce'];
    $nonce_action = 'banner_nonce_action';

    if ( ! isset( $nonce_name ) )
        return;
    if ( ! wp_verify_nonce( $nonce_name, $nonce_action ) )
        return;
    if ( ! current_user_can( 'edit_post', $post_id ) )
        return;
    if ( wp_is_post_autosave( $post_id ) )
        return;
    if ( wp_is_post_revision( $post_id ) )
        return;

    $banner_title_data = isset( $_POST[ 'banner_title_data' ] ) ?  $_POST[ 'banner_title_data' ]  : '';
    $banner_description_data = isset( $_POST[ 'banner_description_data' ] ) ? $_POST[ 'banner_description_data' ] : '';

    // Update the meta field in the database.
    update_post_meta( $post_id, 'banner_title_data_', $banner_title_data );
    update_post_meta( $post_id, 'banner_description_data_', $banner_description_data );

}
函数全局\横幅\设置\元\框(){ $post\u id=$\u GET['post']?$\u GET['post']:$\u post['post\u id']; 添加元框( “横幅设置数据”, __(“横幅设置”、“启动PM”), “render_metabox”, “第页”, "先进",, “默认” ); } 函数render_metabox($post){ 现场发电机(员额); } 函数字段生成器($post){ wp_nonce_字段('banner_nonce_action','banner_nonce'); $banner\u title\u data=get\u post\u meta($post->ID,'banner\u title\u data',true); $banner\u description\u data=get\u post\u meta($post->ID,'banner\u description\u data',true); if(空($banner\u title\u data)){$banner\u title\u data='';} if(空($banner\u description\u data)){$banner\u description\u data='';} $banner_html_code=''; $banner\u html\u代码=''; $banner\u html\u代码=''; $banner_html_code.=''。uuu('banner Title','launchpm'); $banner\u html\u代码=''; $banner\u html\u代码=''; $banner\u html\u code.='使用ob\u start()和ob\u get\u contents()。

 ob_start();
         wp_editor($content, 'text', array(
            'wpautop' => true,
            'media_buttons' => false,
            'textarea_rows' => 5
            )
            );
         $output = ob_get_clean();

        echo '
        <div class="inside">
    <div>
        <label>Title</label>
        <input type="text" name="title[]">
    </div>
    <div>
        <label>Type</label>
        <input type="text" name="type[]">
    </div>
   <div style="clear:both"></div>
    <div>
        <label>Content</label>
        '.$output.'
    </div>
</div>';
通常还有两个与之配对的函数:ob_get_contents(),它基本上为您提供自使用ob_start()打开缓冲区以来“保存”到缓冲区的内容,然后是ob_end_clean()或ob_flush()

附加输出。

 ob_start();
         wp_editor($content, 'text', array(
            'wpautop' => true,
            'media_buttons' => false,
            'textarea_rows' => 5
            )
            );
         $output = ob_get_clean();

        echo '
        <div class="inside">
    <div>
        <label>Title</label>
        <input type="text" name="title[]">
    </div>
    <div>
        <label>Type</label>
        <input type="text" name="type[]">
    </div>
   <div style="clear:both"></div>
    <div>
        <label>Content</label>
        '.$output.'
    </div>
</div>';

代码。

 ob_start();
         wp_editor($content, 'text', array(
            'wpautop' => true,
            'media_buttons' => false,
            'textarea_rows' => 5
            )
            );
         $output = ob_get_clean();

        echo '
        <div class="inside">
    <div>
        <label>Title</label>
        <input type="text" name="title[]">
    </div>
    <div>
        <label>Type</label>
        <input type="text" name="type[]">
    </div>
   <div style="clear:both"></div>
    <div>
        <label>Content</label>
        '.$output.'
    </div>
</div>';
ob_start();
wp_编辑器($content,'text',数组)(
“wpautop”=>true,
“媒体按钮”=>错误,
“textarea_rows”=>5
)
);
$output=ob_get_clean();
回声'
标题
类型
内容
“.$output。”
';

@theKing,您好,请尝试上面的代码。它将按照您的预期工作。它根据需要添加到下面,但无法在编辑器中输入任何文本,它不可单击,而且富格文本格式按钮也缺失。对我来说,它正在工作。所有按钮都如您在问题中提到的那样显示。在编辑器div上方使用clear:和checkOkay,它正在工作。我有
foreach
循环,这是不起作用的地方。我有多个元盒(
)。我用文本附加了更新图像。如果它按预期工作,请标记此答案。