Example 1 — Show a note on the main site
Print a message only on the main site.
<?php if ( is_main_site() ) {
echo 'Welcome to the main site.';
} else {
echo 'Welcome to a sub-site.';
} ?> How It Works
is_main_site()checks the current site.- The
ifbranch runs on the main site. - Sub-sites use the
elsebranch.

