WordPress 的 get_bloginfo 也可以顯示部落格的資訊,而且根據引數的不同,輸出不同的資訊。
其後不跟引數時,get_bloginfo() 預設顯示部落格名稱,例如 「phpdo」;
WordPress 的 get_bloginfo 函式引數詳解:
name:(預設) 返回管理面板> 設定> 常規中設定的部落格標題。
可從 wp_option 資料庫表的 blogname 記錄中獲取 name 資訊。
description:返回管理面板> 設定> 常規中設定的部落格說明/標語。
可從 wp_option 資料庫表的 blogdescription 記錄中獲取 name 資訊。
url:返回部落格地址 (URI),可以在管理面板> 設定> 常規中設定。
可從 wp_option 資料庫表的 home 記錄中獲取該 url 資訊。
wpurl:返回 WordPress 安裝地址,在管理面板> 設定> 常規中設定。
可從 wp_option 資料庫表的 siteurl 記錄中獲取該資訊。
rdf_url:返回部落格 RDF/RSS 1.0 訂閱 URL (/feed/rfd) 。
rss_url:返回部落格 RSS 0.92 訂閱 URL (/feed/rss)
rss2_url:返回部落格 RSS 2.0 訂閱 URL (/feed)
atom_url:返回部落格 Atom 訂閱 URl(/feed/atom)
comments_rss2_url:返回部落格評論 RSS 2.0 訂閱 URL(/comments/feed)
pingback_url:返回 pingback XML-RPC 檔案的 URL(xmlrpc.php)
stylesheet_url:返回當前主題主 CSS 檔案 (通常為 style.css) 的 URL
stylesheet_directory:返回當前主題樣式表資料夾的 URL 。 (WordPress 早期時為本地路徑)
template_directory,template_url:返回當前主題目錄的 URL 。 (在 WP 2.6 之前,template_directory 為本地路徑;其它用法請見 get_theme_root() 與 get_template() 。)
admin_email:返回管理面板> 設定> 常規中設定的部落格管理者的 E-mail 地址。可從 wp_option 資料庫表的 admin_email 記錄中獲取該資訊。
charset:返回管理面板> 設定> 常規中設定的頁面和 feeds 的編碼方式。
可從 wp_option 資料庫表的 blog_charset 記錄中獲取該資訊。
version:返回當前使用的WordPress版本資訊。
該資訊即 wp-includes/version.php 中設定的 $wp_version 變數的值。
html_type:返回 WordPress 的 HTML 頁面的文字型別 (預設:text/html)
儲存在 wp_option 資料庫表的 html_type 記錄中,主題和外掛都可以透過 pre_option_html_type 過濾器改寫 html_type 的預設值 (參見外掛 API/常用過濾器 (filter)) 。
例如:
預設用法將部落格標題賦予變數 $blog_title
<?php $blog_title = get_bloginfo(); ?>
將部落格標題賦值給變數 $blog_title,返回的值與預設用法相同
<?php $blog_title = get_bloginfo(『name』); ?>
部落格描述
使用以下程式碼:
<?php echo 『Your Blog Tagline is: 『 . get_bloginfo ( 『description』 ); ?><br />
在部落格上顯示:
Your Blog Tagline is: phpdo 是我學習PHP以及用 PHP 做程式和學習 seo 的記錄平臺。從 PHP 的基礎語法到 PHP 的高階應用,從 WordPress 到 seo 你都能發現我的實踐。
例如:
在 WP 2.7 中,假設 example 為部落格名,部落格地址為 http://example/home,WordPress 安裝地址為 http://example/home/wp 。
注意其中的目錄 URL 沒有結尾斜線。
admin_email = admin@example
atom_url = http://example/home/feed/atom
charset = UTF-8
comments_atom_url = http://example/home/comments/feed/atom
comments_rss2_url = http://example/home/comments/feed
description = Just another WordPress blog
home = http://example/home
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http://example/home/wp/xmlrpc.php
rdf_url = http://example/home/feed/rdf
rss2_url = http://example/home/feed
rss_url = http://example/home/feed/rss
siteurl = http://example/home
stylesheet_directory = http://example/home/wp/wp-content/themes/largo
stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css
template_directory = http://example/home/wp/wp-content/themes/largo
template_url = http://example/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://example/home
version = 2.7
wpurl = http://example/home/wp