2013-05-25 105 views
0

我有興趣設置一個沒有根級別的博客的多站點安裝。我期望的站點結構如下有沒有辦法在root下沒有博客的情況下運行wordpress多站點?

http://www.group-site.com/blog/

http://www.group-site.com/division-site-one/blog/

http://www.group-site.com/division-site-two/blog/

http://www.group-site.com/division-site-three/blog/

等等....

所以我的團隊網站的博客中託管它在blg文件夾上,我的嵌套分區網站有他們的bl在他們的文件夾中。

這可能嗎?

感謝

回答

1

從我的經驗,我只是把一個佔位符頁面,在根一個最基本的主題,並阻止從根使用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'); 

?> 
相關問題