Using WordPress ‘ms_not_installed()’ PHP function

The ms_not_installed() WordPress PHP function displays a failure message when a blog’s tables do not exist. It also checks for a missing $wpdb->site table.

Usage

ms_not_installed($domain, $path);

Custom Example:

ms_not_installed('example.com', '/blog/');

Parameters

  • $domain (string) – The requested domain for the error to reference.
  • $path (string) – The requested path for the error to reference.

More information

See WordPress Developer Resources: ms_not_installed()

Examples

Basic usage

Display a failure message for a missing blog table.

ms_not_installed('mywebsite.com', '/myblog/');

Non-existent subdomain

Display a failure message for a missing blog table on a subdomain.

ms_not_installed('subdomain.mywebsite.com', '/');

Custom path

Display a failure message for a missing blog table with a custom path.

ms_not_installed('mywebsite.com', '/custom/path/');

Subdirectory

Display a failure message for a missing blog table in a subdirectory.

ms_not_installed('mywebsite.com', '/blog/subdirectory/');

Handling error in a function

Create a function to handle the missing blog table error and display a custom message.

function handle_missing_blog($domain, $path) {
  ms_not_installed($domain, $path);
  echo "The blog at " . $domain . $path . " could not be found.";
}

handle_missing_blog('mywebsite.com', '/missingblog/');