I wanted to create a plugin to batch manage posts’ custom field data. I know I can add post meta by adding a meta box in the post edit screen and using add_action('save_post', 'function_to_update_meta') to trigger add meta functions.
But I don’t know how to trigger the add_post_meta function in an admin menu page (such as a custom admin menu). How to do that?
Thank you in advance!
The answer was from the same question I asked somewhere else
And I created my version of example
I added some console.log function for testing, but this is basically doning the same thing as @Chris_() answer:
Menu callback function to generate menu content (PHP):
Then the javascript to print on the admin side (javascript, don’t forget to include a jquery library):
Then the PHP function handle update_post_meta (PHP):