There is no "Boxpost" and probably why you have not found yet how to do, because the correct name of this is "Metabox".
It has complete documentation about this and in Portuguese in https://codex.wordpress.org/pt-br:add_meta_box
In case it is quite simple to be done, you will get your "Metabox" and inside it "Custom Fields" (also easy to find with the name "Post meta").
Here’s an example of how to register your "Metaboxes" and save your "Custom Fields":
// Register metabox
add_action( 'add_meta_boxes', 'myplugin_add_custom_box' );
// Salvar custom fields
add_action( 'save_post', 'myplugin_save_postdata' );
/* Adiciona uma meta box na coluna principal das telas de edição de Post e Página */
function myplugin_add_custom_box() {
$screens = array( 'post', 'page' );
foreach ($screens as $screen) {
add_meta_box(
'myplugin_sectionid',
__( 'My Post Section Title', 'myplugin_textdomain' ),
'myplugin_inner_custom_box',
$screen
);
}
}
/* Imprime o conteúdo da meta box */
function myplugin_inner_custom_box( $post ) {
// Faz a verificação através do nonce
wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );
// Os campos para inserção dos dados
// Use get_post_meta para para recuperar um valor existente no banco de dados e usá-lo dentro do atributo HTML 'value'
$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" />';
}
/* Quando o post for salvo, salvamos também nossos dados personalizados */
function myplugin_save_postdata( $post_id ) {
// É necessário verificar se o usuário está autorizado a fazer isso
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ) {
return;
}
} else {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
}
// Agora, precisamos verificar se o usuário realmente quer trocar esse valor
if ( ! isset( $_POST['myplugin_noncename'] ) || ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) ) {
return;
}
// Por fim, salvamos o valor no banco
// Recebe o ID do post
$post_ID = $_POST['post_ID'];
// Remove caracteres indesejados
$mydata = sanitize_text_field( $_POST['myplugin_new_field'] );
// Adicionamos ou atualizados o $mydata
update_post_meta( $post_ID, '_my_meta_value_key', $mydata );
}
Note that Custom field was saved in update_post_meta($post_ID, '_my_meta_value_key', $mydata);
and with that the key to the field is _my_meta_value_key
.
This way it is possible to recover this value inside the post loop using get_post_meta( $post->ID, '_my_meta_value_key', true );
.
You can learn more about Custom Fields in official documentation also, but in English.
give a look ai partner see if help http://www.marcelotorresweb.com/usando-taxonomia-e-posts-personalizados-no-wordpress-3-0/
– Otto
Maybe what you want is to create a new custom taxonomy and make it subordinate to normal posts (instead of subordinating to a CPT, custom post type).
– brasofilo