GeekerCode更好的WordPress主题,值得信任的WordPress主题开发商

极美的主题、极致的插件

WordPress模板标签bloginfo()的使用

摘要:【函数介绍】wordpress在模板开发过程中可以使用bloginfo()函数来输出站点的脚本信息,比如站点标题,站编码,站点地址等。这些参数可以在通过“设置=》常规”菜单中进行设置,如果你不想直接输出,而是获取站点的信息你可以通过函数ge

【函数介绍】

wordpress在模板开发过程中可以使用bloginfo()函数来输出站点的脚本信息,比如站点标题,站编码,站点地址等。这些参数可以在通过“设置=》常规”菜单中进行设置,如果你不想直接输出,而是获取站点的信息你可以通过函数get_bloginfo()来返回站点的信息。

【使用方法】

<?php bloginfo( $show ); ?> 

【参数说明】

$show参数是你想要输出的字段名称,你可以通过get_bloginfo()查看具体的参数信息,默认情况下返回站点的标题(name),以下列出各个参数值得实例:

参数名                  返回值实例(根据自己站点后台的配置)

  • name                 = Testpilot
  • description          = Just another WordPress blog
  • admin_email          = admin@example
  • url                  = http://example/home
  • wpurl                = http://example/home/wp
  • stylesheet_directory = http://example/home/wp/wp-content/themes/child-theme
  • stylesheet_url       = http://example/home/wp/wp-content/themes/child-theme/style.css
  • template_directory   = http://example/home/wp/wp-content/themes/parent-theme
  • template_url         = http://example/home/wp/wp-content/themes/parent-theme
  • atom_url             = http://example/home/feed/atom
  • rss2_url             = http://example/home/feed
  • rss_url              = http://example/home/feed/rss
  • pingback_url         = http://example/home/wp/xmlrpc.php
  • rdf_url              = http://example/home/feed/rdf
  • comments_atom_url    = http://example/home/comments/feed/atom
  • comments_rss2_url    = http://example/home/comments/feed
  • charset              = UTF-8
  • html_type            = text/html
  • language             = en-US
  • text_direction       = ltr
  • version              = 3.1

【标签实例】

1、显示博客标题

在<h1>标签中显示你的博客标题。

<h1><?php bloginfo('name'); ?></h1>

2、显示带链接的博客标题

<a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>

3、显示字符集

显示博客正在使用的字符集(如: utf-8)。

<p>Character set: <?php bloginfo('charset'); ?> </p>

4、显示博客描述

<p><?php bloginfo('description'); ?> </p>

建站!你有充足的理由选择我们

世界上超过30%的网站是由WordPress搭建,而我们是国内最靠谱的WordPress主题开发商
QQ咨询在线咨询问答互助微信号geekercode微信公众号云服务器