• Hi, right now me and my team working for multisite, we have prelive domain, admin domain, and public domain, is it possible to change the domain name in wp-admin/network/new-site.php?

    echo get_network()->domain . get_network()->path;
Viewing 2 replies - 1 through 2 (of 2 total)
  • Chat GPT

    Changing the domain name directly in the wp-admin/network/new-site.php file might not be the best approach, as it could lead to various issues within your WordPress multisite installation. Instead, you should use the appropriate WordPress functions and methods to manage the domain and path for a network.

    If you want to set a different domain for a new site in a multisite network, you can use the wpmu_create_blog() function. Here’s an example of how you can do it:

    phpCopy code

    $site_id = wpmu_create_blog( 'newsite', '/new-site-path/', 'New Site Title', get_current_user_id(), array( 'public' => 1 ) );

    In this example:

    • 'newsite' is the new site’s domain.
    • '/new-site-path/' is the path for the new site.
    • 'New Site Title' is the title of the new site.
    • get_current_user_id() is the user ID of the person creating the site.
    • array( 'public' => 1 ) makes the site publicly accessible.

    Adjust the parameters according to your requirements.

    Remember to replace 'newsite' and '/new-site-path/' with the desired domain and path for your new site. Using the appropriate WordPress functions ensures that the necessary database entries and configurations are set correctly.

    Make sure to test this code on a staging environment first to avoid any potential issues on your live site. Additionally, consider backing up your database before making any changes.

    You would like to change the exsisting site domain? Chat GPT

    If you want to change the domain of an existing site in a WordPress multisite network, you can use the update_blog_details() function. Here’s an example of how you can do it:

    phpCopy code

    // Get the site ID of the existing site $site_id = get_id_from_blogname('your-existing-site'); // New domain and path $new_domain = 'new-domain'; $new_path = '/new-path/'; // Update the site details update_blog_details($site_id, array('domain' => $new_domain, 'path' => $new_path));

    Replace 'your-existing-site', 'new-domain', and '/new-path/' with the appropriate values for your site.

    Keep in mind that changing the domain of an existing site in a multisite network can be complex, and it’s crucial to be cautious. You may also need to update the site’s home and siteurl values in the database options table. Additionally, consider updating the wp_blogs table if necessary.

    Always backup your database before making such changes, and thoroughly test on a staging environment first to ensure everything works as expected.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change domain name in wp-admin/network/site-new.php’ is closed to new replies.