ajax – How to Call WP Function from JS


I am trying create a button that allows comment authors to delete their comments. In my comments.php I have::

<button onclick="test()"> Click </button>

    function test() {
      // I want to call wp_delete_comment() here

but I am not sure how to do this. I’ve tried looking at many solutions for other people using AJAX but have had no success. Could someone describe how I can accomplish this?

Nicolas Gimelli 2 months 2022-05-27T16:06:05-05:00 0 Answers 0 views 0

Leave an answer