Below is the code am using to create custom metabox on WordPress, the Metabox shows fine but when I save the post it doesn’t dump the values into the page. It should dump the values from this function “product_meta_box_save“, which is telling WordPress to fire off on Page Save.
<?php
// Little function to return a custom field value
function product_get_custom_field( $value ) {
global $post;
}
// Register the Metabox
function product_add_custom_meta_box() {
add_meta_box( 'about-products-', __( 'About the Product'), 'product_meta_box_output', 'products', 'normal', 'high' );
}
add_action( 'add_meta_boxes', 'product_add_custom_meta_box' );
// Output the Metabox
function product_meta_box_output( $post ){
?>
<table width="100%">
<tr>
<td width="18%"><?php _e("Product Price (FJD)"); ?></td>
<td width="82%"><input type="text" size="20" name="product_price"/></td>
</tr>
<tr>
<td><?php _e("Product Stock"); ?></td>
<td><input type="number" size="50" name="product_stock"/></td>
</tr>
</table>
<?php }
// Save the Metabox values
function product_meta_box_save( $post_id ) {
global $post;
var_dump( $post );
}
add_action( 'save_post', 'product_meta_box_save' );
Yes as David said it uses ajax to save the post so it won’t ever show you that data.
Instead you should do something like this with the save function:
And this way the data will save and as David said you can dump it out then and do whatever you want with it.