Delete data from database in wordpress custom theme

We’re going to dive into the world of WordPress and learn how to create a custom CRUD (Create, Read, Update, Delete) system in the WordPress admin area without relying on plugins. This tutorial will walk you through creating your own tables and managing data within them.

delete-events.php

<?php

global $wpdb;

if (isset($_GET['del'])) { 
$del_id = $_GET['del'];
$wpdb->query("DELETE FROM wp_events WHERE id='$del_id'");

echo "<script>location.replace('admin.php?page=my-events');</script>";
}

?>

 

 

 

 

 

 

 

Leave a Reply