Input value from metabox is not found in $_POST after post save

The $_POST[”] has to contain the name attribute of the input field and not the ID. So to modify your code: function silly_display_metabox( $post ) { wp_nonce_field( basename( __FILE__ ), ‘silly_extrnum_nonce’ ); ?> <label for=”sillyNum”>Silly Number</label> <input type=”number” id=”sillyNum” name=”sillyNum” placeholder=”Write a number…”> <?php } And function silly_save_metabox( $post_id ) { $is_autosave = wp_is_post_autosave( $post_id … Read more

How to send Ajax request from my plugin in admin dashboard?

Here’s a base snippet I use for AJAX submits in WordPress. It does use jQuery, but there’s no reason vanilla won’t work. You could admin_enqueue_scripts() the <script>, and conditionalize it on the proper page with get_current_screen(). add_action( ‘admin_menu’, function(){ add_menu_page( ‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘my_plugin_slug’, ‘my_plugin_page’, ‘dashicons-cloud’ ); }); function my_plugin_page() { if (isset($_POST[‘my_plugin_ajax_submit’])) … Read more