Who can help me a little.
I try to get an admin error notice if a metabox field is empty during save post. Wordpress refresh the page after saving so the hook admin_notices does not work.
Here is my saving code
add_action('save_post', function($post_id){ if(isset($_POST['add']) && $_POST['add'] != ''){ update_post_meta($post_id, 'add', $_POST['add']); }else{ add_action( 'admin_notices', function(){ ?> <p><?php _e( 'Error!', 'Field add is empty!' ); ?></p> <?php }); } }
requiredattribute to the meta field?