WordPress函数文档get_bloginfo()

获取博客站点相关信息 描述 返回你博客的信息,这些信息可以用在任何地方的 PHP 代码中。这个函数,和 blo…

获取博客站点相关信息

描述

返回你博客的信息,这些信息可以用在任何地方的 PHP 代码中。这个函数,和 bloginfo() 一样,可以用来在模板文件的任何地方显示你博客的信息。

用法

 <?php $bloginfo get_bloginfo$show$filter ); ?> 

参数

$show

(string) (可选) Keyword naming the information you want.

默认值: name

  • name’ – Returns the “Site Title” set in Settings > General. This data is retrieved from the “blogname” record in the wp_options table.
  • description’ – Returns the “Tagline” set in Settings > General. This data is retrieved from the “blogdescription” record in the wp_options table.
  • wpurl’ – Returns the “WordPress address (URL)” set in Settings > General. This data is retrieved from the “siteurl” record in the wp_options table. Consider using site_url() instead, especially for multi-site configurations using paths instead of subdomains (it will return the root site not the current sub-site).
  • url’ – Returns the “Site address (URL)” set in Settings > General. This data is retrieved from the “home” record in the wp_options table. Equivalent to home_url().
  • admin_email’ – Returns the “E-mail address” set in Settings > General. This data is retrieved from the “admin_email” record in the wp_options table.
  • charset’ – Returns the “Encoding for pages and feeds” set in Settings > Reading. This data is retrieved from the “blog_charset” record in the wp_options table.
  • version’ – Returns the WordPress Version you use. This data is retrieved from the $wp_version variable set in wp-includes/version.php.
  • html_type’ – Returns the Content-Type of WordPress HTML pages (default: “text/html”). This data is retrieved from the “html_type” record in the wp_options table. Themes and plugins can override the default value using the pre_option_html_type filter.
  • text_direction’ – Returns the Text Direction of WordPress HTML pages. Consider using is_rtl() instead.
  • language’ – Returns the language of WordPress.
  • stylesheet_url’ – Returns the primary CSS (usually style.css) file URL of the active theme. Consider using get_stylesheet_uri() instead.
  • stylesheet_directory’ – Returns the stylesheet directory URL of the active theme. (Was a local path in earlier WordPress versions.) Consider using get_stylesheet_directory_uri() instead.
  • template_url’ / ‘template_directory’ – URL of the active theme’s directory (‘template_directory’ was a local path before 2.6; see get_theme_root() and get_template() for hackish alternatives.) Within child themes, both get_bloginfo(‘template_url’) and get_template() will return the parent theme directory. Consider using get_template_directory_uri() instead (for the parent template directory) or get_stylesheet_directory_uri() (for the child template directory).
  • pingback_url’ – Returns the Pingback XML-RPC file URL (xmlrpc.php).
  • atom_url’ – Returns the Atom feed URL (/feed/atom).
  • rdf_url’ – Returns the RDF/RSS 1.0 feed URL (/feed/rfd).
  • rss_url’ – Returns the RSS 0.92 feed URL (/feed/rss).
  • rss2_url’ – Returns the RSS 2.0 feed URL (/feed).
  • comments_atom_url’ – Returns the comments Atom feed URL (/comments/feed).
  • comments_rss2_url’ – Returns the comments RSS 2.0 feed URL (/comments/feed).
  • siteurl’ – Deprecated since version 2.2. Use home_url(), or get_bloginfo(‘url’).
  • home’ – Deprecated since version 2.2. Use home_url(), or get_bloginfo(‘url’).

$filter

(string) (可选) Keyword specifying how to filter what is retrieved.

默认值: raw

  • display’ – Passes the value of $show through the wptexturize() function before returning it to caller.
  • raw’ – Returns the value of $show as is.

示例

Default Usage

The default usage assigns your blog’s title to the variable $blog_title.

Blog Title

This example assign your blog’s title to the variable $blog_title. This returns the same result as the default usage.

Blog Tagline

Using this example:

results in this being displayed on your blog:

Network Tagline

Using this example, you can obtain the name and description for the network home:

results in this being displayed on your blog:

Template Directory

Returns template directory URL to the active theme.

Example output

From version 2.7. On host example, the Blog address (URL) is shown at http://www.example.com/home, and the WordPress address (URL) is installed at http://www.example.com/home/wp.

Note that directory URLs are missing trailing slashes.

历史

添加于 版本: 0.71

源文件

get_bloginfo() 函数的代码位于 wp-includes/general-template.php.

相关

  • bloginfo()
  • get_admin_url()

Theme paths:
get_template(),
get_template_directory(),
get_template_directory_uri(),
get_theme_roots(),
get_theme_root(),
get_theme_root_uri(),
get_stylesheet(),
get_stylesheet_uri(),
get_stylesheet_directory(),
get_stylesheet_directory_uri(),
get_bloginfo()

  • 原文:http://codex.wordpress.org/Function_Reference/get_bloginfo
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT