I am using three site multi-site installation.
When I use $wpdb->base_prefix
some time it gives network site prefix instead of giving base site prefix. Any one face this problem? Can you please give any suggestion?
I am using three site multi-site installation.
When I use $wpdb->base_prefix
some time it gives network site prefix instead of giving base site prefix. Any one face this problem? Can you please give any suggestion?
2 Answers
Reset to default 16$wpdb->base_prefix
gets the original prefix (ie, the 'root' site in a Multisite installation). It was added in Version 3.0.0, right when Multisite became a part of WordPress core.
$wpdb->prefix
will get the prefix for the current site in a Multisite installation.
Per the documentation for the wpdb
class:
$prefix
The assigned WordPress table prefix for the site.$base_prefix
The original prefix as defined inwp-config.php
. For multi-site: Use if you want to get the prefix without the blog number appended.
(emphasis added)
Try $wpdb->get_blog_prefix like below:
$base_prefix = $wpdb->get_blog_prefix(0);
And use $base_prefix
as base prefix.
Let me know if this is not work for you.
$wpdb->prefix
instead? If you can post some of the relevant code, we may have a better chance of helping you. – Pat J Commented Oct 20, 2016 at 14:03