WordPress功能函数bloginfo()

WordPress功能函数bloginfo(),显示关于当前站点的信息。bloginfo( st

WordPress功能函数bloginfo()

WordPress功能函数bloginfo(),显示关于当前站点的信息。
用法:
bloginfo( string $show = \’\’ )
描述
参见also
get_bloginfo():可能的$show值
参数
$show
(string) (可选) 显示站点信息。
默认值: \’\’
更多信息
显示关于你的站点的信息,大部分来自你在你的用户配置文件和一般设置WordPress管理屏幕上提供的信息。它可以在模板文件中的任何地方使用。这总是向浏览器打印结果。如果需要在PHP中使用这些值,可以使用get_bloginfo()。
来源
文件: wp-includes/general-template.php
function bloginfo( $show = \’\’ ) {
echo get_bloginfo( $show, \’display\’ );
}
更新日志:

用户贡献的笔记
(由Codex – 6年前贡献)
显示博客标题
在标签中显示博客的标题。
<h1><?php bloginfo( \’name\’ ); ?></h1>
(由josephbydesign提供- 5年前)
如果使用bloginfo作为变量,例如:$url = bloginfo(\’url\’);它将返回null。这是因为bloginfo()会立即响应结果。因此,如果您想使用任何一个bloginfo()参数作为变量,请使用get_bloginfo()。这个函数以字符串的形式返回结果。
(由Codex – 6年前贡献)
显示博客描述
按照设置>常规显示你的博客的标记。
<p><?php bloginfo(\’description\’); ?> </p>
(由Codex – 6年前贡献)
示例输出
在本例中,站点地址(URL)为http://www.example.com/home, WordPress地址(URL)为http://www.example.com/home/wp。
请注意,目录url的末尾缺少斜杠。
admin_email = admin@example.com
atom_url = http://www.example.com/home/feed/atom
charset = UTF-8
comments_atom_url = http://www.example.com/home/comments/feed/atom
comments_rss2_url = http://www.example.com/home/comments/feed
description = Just another WordPress blog
home = http://www.example.com/home (DEPRECATED! use url option instead)
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http://www.example.com/home/wp/xmlrpc.php
rdf_url = http://www.example.com/home/feed/rdf
rss2_url = http://www.example.com/home/feed
rss_url = http://www.example.com/home/feed/rss
siteurl = http://www.example.com/home (DEPRECATED! use url option instead)
stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo
stylesheet_url = http://www.example.com/home/wp/wp-content/themes/largo/style.css
template_directory = http://www.example.com/home/wp/wp-content/themes/largo
template_url = http://www.example.com/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://www.example.com/home
version = 3.5
wpurl = http://www.example.com/home/wp
(由Themonic贡献- 5年前)
可以在主题中使用的实例。如果为空,则隐藏描述。
<?php if ( get_bloginfo( \’description\’ ) !== \’\’ ) { ?>
<a class=\”site-description\”><?php bloginfo( \’description\’ ); ?></a>
<?php } ?>
(由Naveen Kharwar在2年前贡献)
<h1><a href=\”<?php bloginfo( \’url\’ ); ?>\”><?php bloginfo( \’name\’ ); ?></a></h1>
<h3><?php bloginfo( \’description\’ ); ?></h3>
(由Codex – 6年前贡献)
在链接中显示博客标题
在链接中显示你的博客的标题。
<a href=\”<?php bloginfo(\’url\’); ?>\” title=\”<?php bloginfo(\’name\’); ?>\”><?php bloginfo(\’name\’); ?></a>
(由Codex – 6年前贡献)
显示字符集
显示你的博客正在使用的字符集(例如\” utf-8 \”)。
注意:在3.5及更高版本中,默认字符编码被设置为UTF-8,并且不能从管理屏幕上进行配置。
<p>Character set: <?php bloginfo(\’charset\’); ?> </p>
(由hiesenberg贡献- 3年前)
在标题中显示网站博客名称
<title><?php bloginfo(\’name\’) ?></title>

作者: liuzhihao

为您推荐

返回顶部