Update blog option during create new blog?

The wpmu_new_blog hook is indeed deprecated and shouldn’t be used; however, it works because it runs after the new site has been initialized (see wp_initialize_site()) which means the database tables for that site has been created and filled with the default options. So because you are updating the site’s options like default_comment_status, then you should … Read more

How to check if page exists in Multisite?

get_page_by_path() will only search in the current site. If you need to find a page anywhere in your Multisite network, you can do something like this. function network_page_exists( $path ) { $args = array( // Max sites to retrieve. // If you have a large network, increase this. ‘number’ => 100, ); $sites = get_sites( … Read more

Is there a way to get plugins and themes not built for multisite to work on a network subsite?

Most plugins and themes don’t need to do anything special to be multisite compatible. Themes especially. So just because a theme or plugin doesn’t say it’s Multisite compatible doesn’t mean it isn’t. Sometimes plugins don’t behave well if you Network Activate them, but the workaround for that is often just to activate them on individual … Read more

WP Multisite – Additional subdomain on the site for API purposes

I have resovled it myself. I have enabled sunrise in wp-config. Then add a script to sunrise.php to override HTTP_HOST. I made it dynamic since we have many websites. When you visit api.domainxy.com it automatically shows you domainxy.com. <?php $re=”/(?:api\.)(.*)/m”; $str = $_SERVER[‘HTTP_HOST’]; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); if ($matches && $matches[0][1] != “”) { … Read more

Using WordPress Multisite to manage multiple projects?

Export/Import like you would the data for any other WordPress install: On the development site: Dashboard -> Tools -> Export -> All Content (save file) Package up the Theme files as “theme-name.zip” Make note of any custom settings On the live site: Install the custom Theme `Dashboard -> Tools -> Import -> WordPress data file … Read more

WordPress MU subdomain vhost

Basically, it turns out you need two dedicated IP addresses, or a third vhost. IP Address You could use two IP addresses and do something like this in your apache configuration: #IP address for WP NameVirtualHost 12.34.56.78:80 #For everything else NameVirtualHost *:80 Then, make sure the VirtualHost for WordPress is declared thus: <VirtualHost 12.34.56.78:80> and … Read more