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?

  • 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 Oct 20 '16 at 14:03

$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 Codex docs for the wpdb class:

The assigned WordPress table prefix for the site.

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)

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.