您的位置:首页 > 其它

Wordpress get_bloginfo函数的参数及用法

2011-11-25 19:53 113 查看
说明

该函数返回用户博客的相关信息,可将返回的信息用在PHP代码中。该函数与bloginfo()均可以显示博客相关信息。

用法

<?php $bloginfo = get_bloginfo( $show ); ?>

参数

$show

(字符串)(可选)可命名你所需要的信息的关键字。

默认值:name

忽略$show参数,或者传递的值不在下面列出的范围内,get_bloginfo返回博客标题。

name

(默认)返回管理面板>设置>常规中设定的博客标题。可从wp_option数据库表的blogname记录中获取name信息。

description

管理面板>设置>常规中设定的博客说明/标语。可从wp_option数据库表的blogdescription记录中获取name信息。

url

博客地址(URI),即博客网站URL,在管理面板>设置>常规中设定。可从wp_option数据库表的home记录中获取该url信息。

wpurl

WordPress地址,即你的WordPress安装地址,在管理面板>设置>常规中设定。可从wp_option数据库表的siteurl记录中获取该信息。

rdf_url

博客 RDF/RSS 1.0订阅URL (/feed/rfd)。

rss_url

博客RSS 0.92 订阅URL (/feed/rss)

rss2_url

博客RSS 2.0 订阅URL (/feed)

atom_url

博客 Atom订阅URl(/feed/atom)

comments_rss2_url

博客评论 RSS 2.0订阅URL(/comments/feed)

pingback_url

pingback XML-RPC文件的URL(xmlrpc.php)

stylesheet_url

当前主题主CSS文件(通常为style.css)的URL

stylesheet_directory

当前主题样式表文件夹的URL。(WordPress早期时为本地路径)

template_directory

template_url

当前主题目录的URL。(在WP 2.6之前,template_directory为本地路径;其它用法请见get_theme_root() 与 get_template()。)

admin_email

在管理面板>设置>常规中设定的博客管理者的E-mail地址。可从wp_option数据库表的admin_email记录中获取该信息。

charset

在管理面板>设置>常规中设定的页面和feeds的编码方式。可从wp_option数据库表的blog_charset记录中获取该信息。

version

当前使用的WordPress版本信息。该信息即wp-includes/version.php中设定的 $wp_version变量的值。

html_type

WordPress的HTML页面的文本类型(默认:text/html);存储在wp_option数据库表的html_type记录中。主题和插件都可以通过 pre_option_html_type过滤器改写html_type的默认值(参见插件API/常用过滤器(filter))。

示例

默认用法

默认用法将博客标题赋予变量$blog_title

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


博客标题

将博客标题赋值给变量$blog_title,返回的值与默认用法相同

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


博客标语

使用以下代码:

<?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' );  ?><br />


使博客上显示:

Your Blog Tagline is: All things WordPress

示例输出

在WP 2.7中,假设example为博客名,博客地址为 http://example/home,WordPress安装地址为 http://example/home/wp

注意其中的目录URL没有结尾斜线。

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: