顯示播客資訊-bloginfo() 函數

來源:互聯網
上載者:User

該標籤顯示使用者部落格的相關資訊,這些資訊通常來自使用者在WordPress網站後台“我的配置”和“設定>常規”菜單中填寫的內容。該標籤可以用在頁面模板的任何地區內,且該標籤總是將結果輸出給瀏覽器。如果使用者需要將輸出內容用在PHP中,請使用get_bloginfo()。

描述

顯示你的部落格資訊,大部分都是顯示WordPress管理介面的 使用者資料 和 常規設定 中的資訊。它可以在模板檔案的任何地方使用。一般 bloginfo() 都是用來直接在瀏覽器中輸出內容的。如果你需要在PHP中傳回值的話,那麼請用 get_bloginfo()。

用法
1
<?php bloginfo($show);?>

參數

$show (字串string) (可選)你需要輸出的資訊的關鍵詞。

預設: name

  • 'name' - 顯示在 設定 > 常規 中設定的“網站標題”。 該資料是從 wp_options 這個資料表中檢索到的 "blogname"記錄。

  • 'description' - 顯示在 設定 > 常規 中設定的“副標題”。該資料是從 wp_options 這個資料表中檢索到的 "blogdescription" 記錄。

  • 'wpurl' - 顯示在 設定 > 常規 中設定的 “WordPress 地址 (URL)”。該資料是從 wp_options 這個資料表中檢索到的 "siteurl" 記錄。 可以考慮使用 site_url() 來代替,尤其是在使用 子目錄路徑方式,而不是使用 子網域名稱 來配置多網站時bloginfo將返回根網站的URL,而不是子網站的URL)。

  • 'siteurl' / 'url' - 顯示在 設定 > 常規 中設定的 “網站地址URL)”)”。該資料是從 wp_options 這個資料表中檢索到的 "home"記錄。 可以考慮使用 home_url() 代替。

  • 'admin_email' - 顯示在 設定 > 常規 中設定的 “電子郵件地址”。該資料是從 wp_options 這個資料表中檢索到的 "admin_email"記錄。

  • 'charset' - 顯示在 設定 > 常規 中設定的“頁面和feed的編碼”。該資料是從 wp_options 這個資料表中檢索到的"blog_charset" 記錄。註:3.5.1+好像已經沒有這個選項了)

  • 'version' - 顯示你當前使用的 WordPress 版本。該資料是在 wp-includes/version.php 檢索到的 $wp_version 這個欄位的值。

  • 'html_type' - 顯示WordPress HTML 頁面中的內容類型預設: "text/html")。該資料可以從 wp_options 這個資料表中檢索到的 "html_type" 記錄。主題和外掛程式可以通過使用 pre_option_html_type 過濾器覆蓋預設值。

  • 'text_direction' - 顯示 WordPress HTML 頁面的文本方向。可以考慮使用 is_rtl() 代替。

  • 'language' - 顯示WordPress的語言。

  • 'stylesheet_url' - 顯示當前使用的主題的 CSS檔案通常為 style.css)路徑。可以考慮使用 get_stylesheet_uri() 代替。

  • 'stylesheet_directory' - 顯示當前使用的主題的樣式表路徑。可以考慮使用 get_stylesheet_directory_uri() 代替。

  • 'template_url' / 'template_directory' - 當前主題的 URL 路徑 。在子主題中, get_bloginfo('template_url') 和 get_template() 都將返回父主題的目錄。可以考慮使用 get_template_directory_uri() 用於父主題目錄)或get_stylesheet_directory_uri() 用於子主題目錄)代替。

  • 'pingback_url' - 顯示通告檔案 XML-RPC 的URL (xmlrpc.php)

  • 'atom_url' - 顯示 Atom feed URL (/feed/atom)

  • 'rdf_url' - 顯示 RDF/RSS 1.0 feed URL (/feed/rfd).

  • 'rss_url' - 顯示 RSS 0.92 feed URL (/feed/rss).

  • 'rss2_url' - 顯示 RSS 2.0 feed URL (/feed).

  • 'comments_atom_url' - 顯示評論的 Atom feed URL (/comments/feed).

  • 'comments_rss2_url' - 顯示評論的 RSS 2.0 feed URL (/comments/feed).

例子

顯示部落格標題

在 <h1> 標籤中顯示部落格標題

1
<h1><?php bloginfo('name');?></h1>

顯示帶連結的部落格標題

顯示一個帶站台連結的部落格標題

1
<a href="<?php bloginfo('url');?>" title="<?php bloginfo('name');?>"><?php bloginfo('name');?></a>

顯示字元集

顯示你部落格設定的字元集例如“UTF-8”)

1
<p>Character set: <?php bloginfo('charset');?> </p>

顯示部落格描述

顯示在 設定 > 常規 中設定的“副標題”

1
<p><?php bloginfo('description');?> </p>

樣本輸出

從 2.7 版開始,在主機中,網站地址URL) 顯示的是 http://www.example.com/home, WordPress 地址 (URL) 是安裝在 http://www.example.com/home/wp。

需要注意的是,這些連結是不帶最後的斜線的!

admin_email          = admin@example.comatom_url             = http://www.example.com/home/feed/atomcharset              = UTF-8comments_atom_url    = http://www.example.com/home/comments/feed/atomcomments_rss2_url    = http://www.example.com/home/comments/feeddescription          = Just another WordPress bloghome                 = http://www.example.com/home (已棄用!使用 url 替代)html_type            = text/htmllanguage             = en-USname                 = Testpilotpingback_url         = http://www.example.com/home/wp/xmlrpc.phprdf_url              = http://www.example.com/home/feed/rdfrss2_url             = http://www.example.com/home/feedrss_url              = http://www.example.com/home/feed/rsssiteurl              = http://www.example.com/home (已棄用!使用 url 替代)stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largostylesheet_url       = http://www.example.com/home/wp/wp-content/themes/largo/style.csstemplate_directory   = http://www.example.com/home/wp/wp-content/themes/largotemplate_url         = http://www.example.com/home/wp/wp-content/themes/largotext_direction       = ltrurl                  = http://www.example.com/homeversion              = 3.5wpurl                = http://www.example.com/home/wp
所在檔案

bloginfo() 包含在 wp-includes/general-template.php。

相關函數

get_bloginfo()

目錄URL標籤

WordPress的目錄:

  • home_url() 首頁URL http://www.example.com

  • site_url() 網站目錄URL http://www.example.com 或 http://www.example.com/wordpress

  • admin_url() 管理目錄URL http://www.example.com/wp-admin

  • includes_url() 包含目錄URL http://www.example.com/wp-includes

  • content_url() 文章目錄URL http://www.example.com/wp-content

  • plugins_url() 外掛程式目錄URL http://www.example.com/wp-content/plugins

  • theme_url() 主題目錄URL http://www.example.com/wp-content/themes

  • wp_upload_dir() 上傳目錄URL (返回一個數組) http://www.example.com/wp-content/uploads


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.