我正在使用视觉作曲家为wordpress的帖子和页面实际上为所有.但我想在帖子编辑器的屏幕下制作一些自定义元框.实际上我已经做了这些领域.但现在我想在视觉作曲家中提供这些字段.实际上我想在可视化编辑器中添加这些字段.我怎样才能做到这一点?请帮助我提供宝贵的知识.
这是我的元框代码
<?PHP function myplugin_add_Meta_Box() { $screens = array( 'post','page' ); foreach ( $screens as $screen ) { add_Meta_Box( 'myplugin_sectionid',__( 'My Post Section Title','myplugin_textdomain' ),'myplugin_Meta_Box_callback',$screen ); } } add_action( 'add_Meta_Boxes','myplugin_add_Meta_Box' ); function myplugin_Meta_Box_callback( $post ) { wp_nonce_field( 'myplugin_save_Meta_Box_data','myplugin_Meta_Box_nonce' ); $value = get_post_meta( $post->ID,'_my_Meta_value_key',true ); echo '<label for="myplugin_new_field">'; _e( 'Description for this field','myplugin_textdomain' ); echo '</label> '; echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . esc_attr( $value ) . '" size="25" />'; } function myplugin_save_Meta_Box_data( $post_id ) { if ( ! isset( $_POST['myplugin_Meta_Box_nonce'] ) ) { return; } // Verify that the nonce is valid. if ( ! wp_verify_nonce( $_POST['myplugin_Meta_Box_nonce'],'myplugin_save_Meta_Box_data' ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page',$post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post',$post_id ) ) { return; } } /* OK,it's safe for us to save the data Now. */ // Make sure that it is set. if ( ! isset( $_POST['myplugin_new_field'] ) ) { return; } // Sanitize user input. $my_data = sanitize_text_field( $_POST['myplugin_new_field'] ); // Update the Meta field in the database. update_post_Meta( $post_id,$my_data ); } add_action( 'save_post','myplugin_save_Meta_Box_data' );
解决方法
我看到你正在回应你的领域作为输入.您需要使用
wp_editor()功能.它将为您完成wysiwyg(可视化编辑器)字段创建.