为了回答我自己的问题,我将首先解释为什么@s\\u ha\\u dum的答案对我不适用。
我正在使用高级自定义字段添加额外的元框,这些元框需要显示在WordPress编辑器上方。
@s\\u ha\\u dum指出WordPress编辑器hardcoded within the template, 但我注意到,可以通过删除对编辑器的支持来禁用它。考虑到这一点,我禁用了对编辑器的支持,然后在新的元框中添加了编辑器的代码。
等等看:
add_action(\'init\', function () {
remove_post_type_support(\'post\', \'editor\');
});
add_action(\'add_meta_boxes\', function () {
$screens = array(\'post\');
foreach ($screens as $screen) {
add_meta_box(
\'moved_editor\',
\'Moved Editor\',
\'moved_editor_custom_box\',
$screen
);
}
});
function moved_editor_custom_box( $post ) {
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), \'myplugin_noncename\' );
?>
<style>
#moved_editor {
border: none;
}
#moved_editor h3 {
display: none;
}
#moved_editor .inside {
padding: 0;
}
</style>
<div id="postdivrich" class="postarea">
<?php wp_editor($post->post_content, \'content\', array(\'dfw\' => true, \'tabfocus_elements\' => \'sample-permalink,post-preview\', \'editor_height\' => 360) ); ?>
<table id="post-status-info" cellspacing="0">
<tbody>
<tr>
<td id="wp-word-count"><?php printf( __( \'Word count: %s\' ), \'<span class="word-count">0</span>\' ); ?></td>
<td class="autosave-info">
<span class="autosave-message"> </span>
<?php if ( \'auto-draft\' != $post->post_status ) : ?>
<span id="last-edit">\'
<?php if ( $last_id = get_post_meta($post_ID, \'_edit_last\', true) ) : ?>
<?php
$last_user = get_userdata($last_id);
printf(__(\'Last edited by %1$s on %2$s at %3$s\'), esc_html( $last_user->display_name ), mysql2date(get_option(\'date_format\'), $post->post_modified), mysql2date(get_option(\'time_format\'), $post->post_modified));
?>
<?php else : ?>
<?php printf(__(\'Last edited on %1$s at %2$s\'), mysql2date(get_option(\'date_format\'), $post->post_modified), mysql2date(get_option(\'time_format\'), $post->post_modified)); ?>
<?php endif; ?>
</span>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
<?
}