WordPress标签——get_bloginfo()
作者:Shellway,文章地址:http://blog.shellway.cn/index.php/wordpress/343,转载请保留此段
简介
get_bloginfo() 函数返回你的博客信息,这些信息可以在PHP代码任何位置使用。本函数同bloginfo(),用法及参数都相同。我们可以通过传入相关参数,用其显示您的博客相应信息。
比如:博客标题(name),博客链接(url),博客描述(description)……等。下面介绍各参数的用法。
参数表
- name:默认参数。返回博客的标题。博客标题可在“后台管理→ 设置→ 常规”中设置,数据保存在表“wp_options”的“blogname”字段中;
- description:返回博客的描述。设置方式同“name”参数。对应数据表“wp_options”中“blogdescription”字段;
- url:博客链接地址。设置方式同“name”参数。对应数据表“wp_options”中“home”字段;
- wpurl:Wordpress安装目录链接地址。设置方式同“name”参数。对应数据表“wp_options”中“siteurl”字段;
- rdf_url:您博客的RDF/RSS 1.0地址;
- rss_url:您博客的RSS 0.92地址;
- rss2_url:您博客的RSS 2.0地址;
- atom_url:您博客的Atom地址;
- comments_rss2_url:您博客评论的RSS 2.0地址;
- pingback_url:Pingback的XML-RPC文件;
- stylesheet_url:主样式表url地址;
- stylesheet_directory:当前主题样式表目录;
- template_directory/template_url:当前主题目录/主题url地址;
- admin_email:管理员email;
- charset:博客页面和Feeds的编码形式,如:utf-8;
- version:博客系统的版本号。文件wp-includes/version.php中$wp_version变量的值;
- html_type:Wordpress的html页面内容类型(Content-Type),默认值text/html,对应数据表“wp_options”中“html_type”字段。可以用pre_option_html_type过滤器,在主题和插件中重写其默认值;
示例
博客标题
<?php $blog_title = get_bloginfo('name'); ?>
博客描述
<?php echo '博客描述: ' . get_bloginfo ( 'description' ); ?>
参数及返回值形式对照如下:
admin_email = admin@example
atom_url = http://example/home/feed/atom
charset = UTF-8
comments_atom_url = http://example/home/comments/feed/atom
comments_rss2_url = http://example/home/comments/feed
description = Just another WordPress blog
home = http://example/home
html_type = text/html
language = en-US
name = Testpilot
pingback_url = http://example/home/wp/xmlrpc.php
rdf_url = http://example/home/feed/rdf
rss2_url = http://example/home/feed
rss_url = http://example/home/feed/rss
siteurl = http://example/home
stylesheet_directory = http://example/home/wp/wp-content/themes/largo
stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css
template_directory = http://example/home/wp/wp-content/themes/largo
template_url = http://example/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://example/home
version = 2.7
wpurl = http://example/home/wp
注:url参数无正斜杠“/”,使用的时候要适当添加;
---------------------------------------------------------
好好学习,天天向上