DELETE Request to REST API
Learn to delete a lecture post using the WordPress REST API.
On the Lecture Notes page, every lecture post has a Delete button associated with it. We will create an event listener to respond to a click event on it.
With the Excellence folder open in VS code, access the terminal by clicking the "View" option and choosing "Terminal". Run the start script using the
npm run start
command. The start script will watch for any changes in the code and recompile it.
Click event on Delete button
To add an event listener to the Delete button, first we will select all Delete buttons in the deleteButtons
variable using the querySelectorAll
method. We gave the Delete button a class of delete-lecture
(in page-lecture-notes.php
).
Get hands-on with 1400+ tech skills courses.