R
Add that code to functions.phpfunction my_properties_add_meta_box() {
add_meta_box(
'my_properties_additional',
'Дополнительное поле',
'my_properties_meta_box_callback',
'page'
);
add_meta_box(
'my_properties_additional_2',
'Дополнительное поле 2',
'my_properties_meta_box_callback_2',
'page'
);
}
function my_properties_meta_box_callback( $post ) {
wp_nonce_field( 'my_properties_meta_box', 'my_properties_meta_box_nonce' );
$creds = array();
$creds['my_properties'] = get_post_meta( $post->ID, '_my_properties', true );
?>
<div>
<?php
wp_editor( $creds['my_properties'], 'my_properties', array(
'textarea_rows' => 9,
) );
?>
</div>
<?php
}
function my_properties_meta_box_callback_2( $post ) {
wp_nonce_field( 'my_properties_meta_box', 'my_properties_meta_box_nonce_2' );
$creds = array();
$creds['my_properties'] = get_post_meta( $post->ID, '_my_properties_2', true );
?>
<div>
<?php
wp_editor( $creds['my_properties'], 'my_properties_2', array(
'textarea_rows' => 9,
) );
?>
</div>
<?php
}
add_action( 'add_meta_boxes', 'my_properties_add_meta_box' );
function my_properties_meta_box_save( $post_id ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! ( isset( $_POST['my_properties_meta_box_nonce'] ) && wp_verify_nonce( $_POST['my_properties_meta_box_nonce'], 'my_properties_meta_box' ) ) ) {
return;
}
if ( ! ( isset( $_POST['my_properties_meta_box_nonce_2'] ) && wp_verify_nonce( $_POST['my_properties_meta_box_nonce_2'], 'my_properties_meta_box' ) ) ) {
return;
}
if ( isset( $_POST['post_type'] ) && 'page' === $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
update_post_meta( $post_id, '_my_properties', $_POST['my_properties'] );
update_post_meta( $post_id, '_my_properties_2', $_POST['my_properties_2'] );
}
}
add_action( 'save_post', 'my_properties_meta_box_save' );
He adds two metaboxes to the editing of the page. You'll be able to increase the ring from 2 to 4.Worker's code, checked on his test site.So it looks like hell.