Creating separate database table for Multisite WordPress

Recently, I have been struggling to get this right. Creating a separate database tables for Multisite.

Multisite has option for “Network Activate”. When enabling the plugin, it should create a separate database table for each of the site. At the same time we also need to consider that it should be deleted when we “uninstall” it. There are also scenarios like creation/deletion of new site under multisite.

I followed various notes on Google, but didn’t work for me then I noticed a plugin “Activity Log” that had this functionality, so getting inspired I re-created a plugin that will just create tables upon activation.

Let me know if you find it useful.

To create a plugin, we need to create a folder inside “Plugins” directory.. lets name it “Custom Test”

Inside it, there should be a file custom-test.php

Now add second file, let’s name it ‘ custom-table.php ‘ in the same folder.

And Voila!

Happy Coding 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *