Error when adding Meta Boxes, but only when adding 3 with the same callback

instead of deleting and creating a new box, try this to just move the existing boxes add_action(“add_meta_boxes_post”, function () { $listBoxId = [ “tagsdiv-ahtscollectionmakes”, “tagsdiv-ahtscollectionyear”, “tagsdiv-ahtscollectionos”, ]; $screen = get_current_screen(); $page = $screen->id; // loop on the “side” boxes foreach ($GLOBALS[“wp_meta_boxes”][$page][“side”] as $priority => $tabPriority) { foreach ($tabPriority as $id => $box) { if (in_array($id, … Read more

Adding Meta Box to Specific Submenu Page

I think for this you want to go with WordPress Setting API. If you prefer meta box. You have to add a do_action in your function which render the page (view_tasks_submenu_page_callback). do_action( ‘add_meta_boxes’, $hook_id ); And add do_meta_boxes($hook_id, $context, null) where you want your meta boxes appear. replace $hook_id by the fourth parameter of add_meta_box … Read more

How Add a Save Button to Custom Meta Box without Leave/Stay js Dialog?

HERE THE SOLUTION: If you want remove the default publish button and use a custom submit button for your Custom Meta Box, you have to insert the submit_button in a <div class=”submitbox” id=”submitpost”></div> e.g. <div class=”submitbox” id=”submitpost”> <?php submit_button( ‘Submit’, ‘primary’, ‘publish’, false ); ?> </div>

Unable to save multiple images in wordpress

You are updating the same post_meta on each loop. Therefore you are probably saving the last uploaded image only. Try something like this (simplified): foreach ($_FILES[‘wp_custom_attachment’][“tmp_name”] as $key => $value) { $post_meta = get_post_meta($id, ‘wp_custom_attachment’, $upload); if( $post_meta ) { $post_meta .= ‘, ‘ . $upload; update_post_meta($id, ‘wp_custom_attachment’, $post_meta); } else { add_post_meta($id, ‘wp_custom_attachment’, $upload); … Read more