WordPress多網站擷取當前部落格資訊_PHP教程

來源:互聯網
上載者:User
http://www.utubon.com/1495/wordpress-multisite-get-current-bolg-info

global $current_blog;

它的返回結果是:

stdClass Object(    [blog_id] => 3    [site_id] => 1    [domain] => demo.utubon.com    [path] => /neighborhood/    [registered] => 2013-08-01 10:31:03    [last_updated] => 2013-08-01 02:31:03    [public] => 1    [archived] => 0    [mature] => 0    [spam] => 0    [deleted] => 0    [lang_id] => 0)

也可以使用get_blog_details函數:

$current_blog = get_blog_details();

它的返回結果是:

stdClass Object(    [blog_id] => 3    [site_id] => 1    [domain] => demo.utubon.com    [path] => /neighborhood/    [registered] => 2013-08-01 10:31:03    [last_updated] => 2013-08-01 02:31:03    [public] => 1    [archived] => 0    [mature] => 0    [spam] => 0    [deleted] => 0    [lang_id] => 0    [blogname] => Neighborhood    [siteurl] => http://demo.utubon.com/neighborhood    [post_count] => )// 比global $current_blog的資訊更多

這基本上就滿足了我們的需要,不過還有一個比較繞彎子的方法,使用get_blog_id_from_url函數。如果你的多網站是使用子目錄的形式,就使用:

$blog_id = get_blog_id_from_url("example.com", "/blog1/");

如果使用的是子網域名稱的形式,就使用:

$blog_id = get_blog_id_from_url("blog1.example.com");

而上面的這些參數,我們可以使用$_SERVER['SERVER_NAME']$_SERVER["REQUEST_URI"]擷取。

獲得$blog_id之後各種事情就好辦了。

http://www.bkjia.com/PHPjc/738537.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/738537.htmlTechArticlehttp://www.utubon.com/1495/wordpress-multisite-get-current-bolg-info global $current_blog; 它的返回結果是: stdClass Object( [blog_id] = 3 [site_id] = 1 [domain] = demo.utu...

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.