This is a solution written basing on Tom J Nowell idea and answer. It prints out sorted list of all sites in Wordpress Multisite installation, as simple line (separated with pipe).
To get this solution running, edit your currently selected theme and select
shortcodes.php from right sidebar. Near the end of this file, before first occurence of
add_shortcode call add following function:
$result = '';
$sites = array();
$blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public='1'"));
foreach($blogs as $blog)
$details = get_blog_details($blog->blog_id);
if($details != false)
$url = $details->siteurl;
$name = $details->blogname;
if(!(($blog->blog_id == 1) && ($show_main != 1)))
$sites[$name] = $url;
$count = count($sites);
$current = 1;
foreach($sites as $name=>$url)
$result.= '<a href="'.$url.'">'.$name.'</a>';
$result.= ($current == $count) ? "\n" : ' | ';
Then scroll down to the end of file and after last occurence of
Update File to save your changes.
Now, whenever anyone use
[network_list] shortcode to in post, page or theme element, a list of network sites will be printed in place of that shortcode.