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