最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

$wpdb->base_prefix not get parent site prefix in multisite

programmeradmin1浏览0评论

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?

Share Improve this question edited Oct 14, 2016 at 9:21 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Oct 14, 2016 at 9:21 KuppurajKuppuraj 1851 silver badge6 bronze badges 1
  • 1 Are you looking for $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
Add a comment  | 

2 Answers 2

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 in wp-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.

发布评论

评论列表(0)

  1. 暂无评论