I am writing a plugin in which I have a js file. I enqueue it with wp_enqueue_script. In this file I have some functions. The functions are triggered by an onclick event of a button. The button is located on edit post page. Now I need those functions to get post meta of the edited post, modify and save.
Does anyone have any idea how to do it?
You can send variables to your script with wp_localize_script:
You can then use the var in your script like: