• I’m writing a plugin on a network installation. I want the plugin to have separate tables for each site. I’ve seen many tables like prefix_1_table in the database, but I can’t find any good description of how to accomplish this. I think I muddled through it once before, but I no longer have access to that source code, so I’m kind of starting over. Can someone point me to a good tutorial?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Sorry, I can’t point to a tutorial, but creating tables is not too difficult. You use the global $wpdb object’s methods, primarily $wpdb->query(). The SQL is simply the usual CREATE TABLE IF NOT EXISTS syntax. You can concatenate the table name with $wpdb->base_prefix . $site_id . '_my_table_name' or similar. You can get the site IDs with get_sites()

    You should be able to muddle that together into something workable ??

Viewing 1 replies (of 1 total)
  • The topic ‘Tables with Site ID’ is closed to new replies.