首页    >    中文手册    >   模板标签-get bloginfo

模板标签-get bloginfo

描述

get_bloginfo() 标签可用来在其它PHP编码中显示你的博客信息。它和bloginfo()都是用来显示博客信息的模板标签。

 

使用

 <?php get_bloginfo('show'); ?> 

 

实例

 

默认使用

默认情况下,系统会把博客标题赋予给变量$blog_title。

<?php $blog_title = get_bloginfo(); ?>

 

博客标题

以下例子把博客标题分配给了变量$blog_title,默认情况下正是这样的。

<?php $blog_title = get_bloginfo('name'); ?>

 

博客描述

使用:

<?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' );  ?> 
博客会显示:
Your Blog Tagline is: All things WordPress

 

模板目录

把模板目录的URL返回当前主题。 以下信息可用来包含searchform.php这个自定义模板。

<?php include(get_bloginfo('template_directory') . '/searchform.php'); ?>

 

实例输出

2.5.1版本之后,目录的URL末尾不再有斜线/了。

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

 

参数

显示
(string)博客详细信息。有效值(Valid values):

  • '' – (默认)显示在管理> 设置> 常规下设置的博客标题,并在wp_options table中的blogname记录中检索。
  • 'name' – 和 '' 显示值一样(默认情况下)。
  • 'description' – 即在管理> 设置> 常规下设置的博客描述,可在wp_options table中的blogdescription记录中检索。
  • 'url'博客地址 (URI) 就是博客网站的URL ,可在管理> 设置> 阅读下设置,并在wp_options table中的home记录中检索。
  • 'home' – 和 'url'显示值一样。
  • 'siteurl' -和 'url'显示值一样。( returns the same value as 'url'.)
    注意: 它和get_settings('siteurl')并不一样;后者会显示WordPress的url。get_bloginfo()和get_settings() 已过时。
  • 'wpurl'WordPress地址(URI)是WordPress安装文件的URL,可在管理> 设置> 阅读下设置。并在wp_options table中的siteurl记录中检索。 
  • 'rdf_url' – RDF/RSS 1.0 feed的URL,博客地址 (URI) 后会带有/feed/rfd这样的字符
  • 'rss_url' – RSS 0.92 feed 的URL,博客地址 (URI) 后会带有/feed/rss这样的字符 
  • 'rss2_url' -RSS 2.0 feed 的 URL, 博客地址 (URI) 后会带有/feed这样的字符
  • 'atom_url' – Atom feed顶端URL ,博客地址 (URI) 后会带有 /feed/atom这样的字符
  • 'comments_rss2_url' – 评论RSS 2.0 feed的URL ,博客地址 (URI) 后会带有/comments/feed这样的字符 
  • 'pingback_url' – Pingback (XML-RPC 文件)的URL,博客地址 (URI) 后会带有 /xmlrpc.php这样的字符 
  • 'stylesheet_url' -主要CSS文件的URL,博客地址 (URI) 后会带有/wp-content/themes和wp_options table中stylesheet (样式表)值及string /style.css这样的字符 如:http://www.sample.com/wordpress/wp-content/themes/default/style.css
  • 'stylesheet_directory' -样式表目录的本地路径。如:/home/you/public_html/wordpress/wp-content/themes/default(在2.3.1版本已过时)
  • 'template_directory' – 模板目录的本地路径。如:/home/you/public_html/wordpress/wp-content/themes/default. (函数已过时,在2.6.2版本会显示URL。get_theme_root()和get_template()是改进后的函数。 )
  • 'template_url' -和 'template_directory' 功能一样,会显示当前模板的URL。
  • 'admin_email' – 管理员的E-mail地址,可在管理> 设置> 阅读下设置。并在wp_options table中的admin_email 记录中检索。
  • 'charset'页面和feed的编码,可在管理> 设置> 阅读下设置。并在wp_options table中的blog_charset记录中检索。
  • 'version' – 所用WordPress的版本号。即 wp-includes/version.php中变量$wp_version的值。
  • 'html_type' -博客的 "Content-type" (内容类型),可在 wp-admin/upgrade-schema.php 中设置,并在wp_options table中的html_type记录中检索。

 

分类:中文手册

* 版权声明:作者WordPress啦! 转载请注明出处。