If I'm running a multi-site setup and I create a new table and add it to the WordPress database, will it be accessible to all sites or is it created to be site specific?
1 Answer
It's up to you.
Normally when you create and query a table you use the $wpdb->prefix property as part of the table name. In a multisite install this prefix includes the current site ID. So if you use dbDelta() to create a table with the name $wpdb->prefix . 'tablename', then — assuming the default prefix of wp_ — this table will be created as wp_2_tablename, and wp_3_tablename etc. This ultimately means that each site in the network gets its own copy of the table, and you query the current site's table with $wpdb->prefix . 'tablename'.
However, if you want a single table shared across the network, then you should create and query it with $wpdb->base_prefix, which will be the same on all sites (wp_, if you use the default). That way if you query it with $wpdb->base_prefix . 'tablename' the same table will be queried regardless of which site you're currently on.