I have created a custom table for meta fields using the guide.
The ID field has been automatically added. It is a primary key, yet it displays the post id which the meta field belongs to.
When I delete that post from wordpress, the custom table entries remain.
How can i reconfigure it so 'ID' is an autoincrementing primary key, and 'post_id' is a foreign key, referencing the post id, and enabling the entry to be deleted when the post is deleted?
Here is the code used for custom table
add_action( 'init', 'prefix_create_table' );
function prefix_create_table() {
if ( ! class_exists( 'MB_Custom_Table_API' ) ) {
return;
}
MB_Custom_Table_API::create( 'my_custom_table', array(
'address' => 'TEXT NOT NULL',
'phone' => 'TEXT NOT NULL',
'email' => 'VARCHAR(20) NOT NULL',
) );
}
Thanks