根据我的经验,我只是将一个占位符页面放在一个基本主题的根目录中,并阻止根目录被 robots.txt 索引。或者在主题的根目录中列出您的所有博客,然后再次使用 robots.txt 阻止它
下面的函数(在主题的 functions.php 文件中)将输出所有博客的列表,并且可以在根目录下用于整个多站点的目录:
<?php
// Automatic list of all sites of the MS isntall, except for the main site (ID 1)
// and output by shortcode [bloglist]
// Output a single menu item
function projects_menu_entry($id, $title, $link_self)
{
global $blog_id;
$out = '';
if ($link_self || $id != $blog_id) {
$out .= '<li>';
if ($id == $blog_id) {
$out .= '<strong>';
}
$url = get_home_url($id);
if (substr($url, -1) != '/') {
// Note: I added a "/" to the end of the URL because WordPress
// wasn't doing that automatically in v3.0.4
$url .= '/';
}
$out .= '<a href="' . $url . '">' . $title . '</a>';
if ($id == $blog_id) {
$out .= '</strong>';
}
$out .= '</li>';
}
return $out;
}
// Output the whole menu
// If $link_self is false, skip the current site - used to display the menu on the homepage
function projects_menu($link_self = true)
{
global $wpdb;
$out = '<ul>';
$out .= projects_menu_entry(1, 'Home', $link_self);
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
AND blog_id != 1
// add another blog_id for any other blog you want to hide like below
// AND blog_id != 19
");
$sites = array();
foreach ($blogs as $blog) {
$sites[$blog->blog_id] = get_blog_option($blog->blog_id, 'blogname');
}
natsort($sites);
foreach ($sites as $blog_id => $blog_title) {
$out .= projects_menu_entry($blog_id, $blog_title, $link_self);
}
$out .= '</ul>';
return $out;
}
// Adds a [bloglist] shortcode
function bloglist_shortcode($atts)
{
return projects_menu(false);
}
add_shortcode('bloglist', 'bloglist_shortcode');
?>