Shellway Blog 关注前端设计,关注互联网发展趋势

142010/110/67

WordPress标签——get_bloginfo()

作者:Shellway,文章地址:http://blog.shellway.cn/index.php/wordpress/343,转载请保留此段

简介

get_bloginfo() 函数返回你的博客信息,这些信息可以在PHP代码任何位置使用。本函数同bloginfo(),用法及参数都相同。我们可以通过传入相关参数,用其显示您的博客相应信息。
比如:博客标题(name),博客链接(url),博客描述(description)……等。下面介绍各参数的用法。

参数表

  1. name:默认参数。返回博客的标题。博客标题可在“后台管理→ 设置→ 常规”中设置,数据保存在表“wp_options”的“blogname”字段中;
  2. description:返回博客的描述。设置方式同“name”参数。对应数据表“wp_options”中“blogdescription”字段;
  3. url:博客链接地址。设置方式同“name”参数。对应数据表“wp_options”中“home”字段;
  4. wpurl:Wordpress安装目录链接地址。设置方式同“name”参数。对应数据表“wp_options”中“siteurl”字段;
  5. rdf_url:您博客的RDF/RSS 1.0地址;
  6. rss_url:您博客的RSS 0.92地址;
  7. rss2_url:您博客的RSS 2.0地址;
  8. atom_url:您博客的Atom地址;
  9. comments_rss2_url:您博客评论的RSS 2.0地址;
  10. pingback_url:Pingback的XML-RPC文件;
  11. stylesheet_url:主样式表url地址;
  12. stylesheet_directory:当前主题样式表目录;
  13. template_directory/template_url:当前主题目录/主题url地址;
  14. admin_email:管理员email;
  15. charset:博客页面和Feeds的编码形式,如:utf-8;
  16. version:博客系统的版本号。文件wp-includes/version.php中$wp_version变量的值;
  17. 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参数无正斜杠“/”,使用的时候要适当添加;

---------------------------------------------------------

好好学习,天天向上

<!-- JiaThis Button BEGIN --> <div id="ckepop"> <a href="http://www.jiathis.com/share/" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享到:</a> <a title="分享到QQ空间" class="jiathis_button_qzone">QQ空间</a> <a title="分享到人人网" class="jiathis_button_renren">人人网</a> <a title="分享到开心网" class="jiathis_button_kaixin001">开心网</a> <a title="分享到新浪微博" class="jiathis_button_tsina">新浪微博</a> </div> <script type="text/javascript" src="http://v1.jiathis.com/code/jia.js" charset="utf-8"></script> <!-- JiaThis Button END -->
评论 (0) 引用 (0)

还没有评论.


Leave a comment

(required)


*

还没有引用.