WordPress:Template Tags/get bloginfo
Description
描述
The get_bloginfo() Template Tag returns information about your blog which can then be used elsewhere in your PHP code. This Template Tag, as well as bloginfo(), can also be used to display your blog information.
得到_bloginfo() 模板标签返回了关于你的博客的信息,这个信息可以在PHP代码的其它位置使用。这个模板标签和bloginfo()也可以用来显示你的博客信息。
Usage
%%% <?php get_bloginfo('show'); ?> %%%
用法
%%% <?php 得到_bloginfo('显示'); ?> %%%
Examples
Default Usage
例子
默认用法
The default usage assigns your blog's title to the variable $blog_title.
默认将你的博客的标题分派给变数$博客_标题。
<?php $blog_title = get_bloginfo(); ?>
<?php $博客_标题 = 得到_bloginfo(); ?>
Blog Title
博客标题
This example assign your blog's title to the variable $blog_title. This returns the same result as the default usage.
这个例子将你的博客的标题分派给变数$博客_标题。
<?php $blog_title = get_bloginfo('name'); ?>
<?php $博客_标题 = 得到_bloginfo('名称'); ?>
Blog Tagline
博客Tagline
Using this example: 使用这个例子:
<?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' ); ?>
<?php echo '你的博客的Tagline 是: ' .得到_bloginfo ( '描述' ); ?>
results in this being displayed on your blog: 结果显示在你的博客上:
Your Blog Tagline is: All things WordPress
你的博客Tagline是: All things WordPress
Template Directory
模板目录
Returns template directory URL to the active theme. This this example the information is used to include a custom template called searchform.php'.
将主题目录URL返回到现行的主题中。这个例子中,信息用来包含一个自定义模板,称作searchform.php'。
<?php include(get_bloginfo('template_directory') . '/searchform.php'); ?>
<?php 包含(得到_bloginfo('模板_目录') . '/searchform.php'); ?>
Example output
例子 output
From version 2.5.1. Note that directory URLs are missing trailing slashes. 从2.5.1版本开始。注意目录URLs缺少拖尾的斜线。
admin_email = me@example atom_url = http://example/blog/feed/atom charset = UTF-8 comments_atom_url = http://example/blog/comments/feed/atom comments_rss2_url = http://example/blog/comments/feed description = Just another WordPress weblog home = http://example/blog html_type = text/html language = name = Testpilot pingback_url = http://example/blog/wp/xmlrpc.php rdf_url = http://example/blog/feed/rdf rss2_url = http://example/blog/feed rss_url = http://example/blog/feed/rss siteurl = http://example/blog stylesheet_directory = http://example/blog/wp/wp-content/themes/largo stylesheet_url = http://example/blog/wp/wp-content/themes/largo/style.css template_directory = http://example/blog/wp/wp-content/themes/largo template_url = http://example/blog/wp/wp-content/themes/largo text_direction = ltr url = http://example/blog version = 2.5.1 wpurl = http://example/blog/wp
admin_email = me@example atom_url = http://example/blog/feed/atom charset = UTF-8 comments_atom_url = http://example/blog/comments/feed/atom comments_rss2_url = http://example/blog/comments/feed description = Just another WordPress weblog home = http://example/blog html_type = text/html language = name = Testpilot pingback_url = http://example/blog/wp/xmlrpc.php rdf_url = http://example/blog/feed/rdf rss2_url = http://example/blog/feed rss_url = http://example/blog/feed/rss siteurl = http://example/blog stylesheet_directory = http://example/blog/wp/wp-content/themes/largo stylesheet_url = http://example/blog/wp/wp-content/themes/largo/style.css template_directory = http://example/blog/wp/wp-content/themes/largo template_url = http://example/blog/wp/wp-content/themes/largo text_direction = ltr url = http://example/blog version = 2.5.1 wpurl = http://example/blog/wp
Parameters
参数
- show
- (string) Informational detail about your blog. Valid values:
;显示:(string)关于你的博客的详细信息。有效的参数值:
- '' - (default) returns the Weblog title set in Administration > Settings > General. This data is retrieved from the blogname record in the wp_options table.
- 'name' - returns the same value as '' (the default).
- '名称' -返回与''一样的值(默认)。
- 'description' - the Tagline set in Administration > Settings > General. This data is retrieved from the blogdescription record in the wp_options table.
- 'url' - the Blog address (URI) is the URL for your blog's web site address and is set in Administration > Settings > General. This data is retrieved from the home record in the wp_options table.
- 'home' - returns the same value as 'url'.
- '主' -返回与'url'相同的值。
- 'siteurl' - returns the same value as 'url'.
Warning: This is not the same as get_settings('siteurl'); which will return the WordPress url. Use get_bloginfo(), get_settings() has been deprecated.
- 'siteurl' - returns the same value as 'url'.
- 'siteurl' -返回与'url'相同的值。注:这与得到_设置('siteurl')不同;得到_设置('siteurl')返回WordPress url。请使用得到_bloginfo(),得到_设置()已经被取消了。
- 'wpurl' - the WordPress address (URI) is the URL for your WordPress installation and is set in Administration > Settings > General. This data is retrieved from the siteurl record in the wp_options table.
- 'rdf_url' - URL for RDF/RSS 1.0 feed which is your Blog address (URI) appended with the string such as /feed/rfd.
- 'rdf_url' -RDF/RSS 1.0 feed的URL,是你的博客地址 (URI),附加字符串,例如/feed/rfd。
- 'rss_url' - URL for RSS 0.92 feed which is your Blog address (URI) appended with the string such as /feed/rss.
- 'rss_url' -RSS 0.92 feed的URL,是你的博客地址(URI),附加字符串,例如/feed/rss。
- 'rss2_url' - URL for RSS 2.0 feed which is your Blog address (URI) appended with the string such as /feed.
- 'rss2_url' - RSS 2.0 feed的URL,是你的博客地址(URI),附加字符串,例如/feed。
- 'atom_url' - URL for Atom feed which is your Blog address (URI) appended with the string such as /feed/atom.
- 'atom_url' -Atom feed的URL,是你的博客地址 (URI),附加字符串,例如/feed/atom。
- 'comments_rss2_url' - URL for comments RSS 2.0 feed which is your Blog address (URI) appended with the string such as /comments/feed.
- '评论_rss2_url' -评论RSS 2.0 feedURL,是你的博客地址 (URI),附加字符串,例如/评论/feed。
- 'pingback_url' - URL for Pingback (XML-RPC file) which is your Blog address (URI) appended with the string /xmlrpc.php.
- 'pingback_url' -Pingback (XML-RPC 文件)的URL,是你的博客地址 (URI),附加字符串/xmlrpc.php。
- 'stylesheet_url' - URL for primary CSS file which is your Blog address (URI) appended with the string composed of /wp-content/themes plus the value of the stylesheet record in the wp_options table plus the string /style.css. For example, http://www.sample.com/wordpress/wp-content/themes/default/style.css
- 'stylesheet_directory' - local path to stylesheet directory. For example, /home/you/public_html/wordpress/wp-content/themes/default.
- '样式表_目录' -样式表目录的本地路径。例如, /home/you/public_html/wordpress/wp-content/themes/default.
- 'template_directory' - local path to template directory. For example, /home/you/public_html/wordpress/wp-content/themes/default.
- '模板_目录' -目录目录的本地路径。例如, /home/you/public_html/wordpress/wp-content/themes/default。
- 'template_url' - the same as 'template_directory' and returns URL for template in use.
- '模板_url' -与'模板_目录'相同而且为正在使用的模板返回URL。
- 'admin_email' - the Administrator's E-mail address set in Administration > Settings > General. This data is retrieved from the admin_email record in the wp_options table.
- 'charset' - the Encoding for pages and feeds set in Administration > Settings > Reading. This data is retrieved from the blog_charset record in the wp_options table.
- 'version' - Version of WordPress your blog uses. This data is the value of $wp_version variable set in wp-includes/version.php.
- '版本' -你的博客使用的WordPress版本。这个数据是设置wp-includes/version.php中的$wp_版本变数的值。
- 'html_type' - "Content-type" for your blog. This value is set in wp-admin/upgrade-schema.php and is retrieved from the html_type record in the wp_options table .
- 'html_type' -你的博客的"文章类型"。这个值设置在wp-admin/upgrade-schema.php而且可以从wp_选项表格中的html_type中得到。