WordPress 中文文档
Function Reference/get bloginfo
出自WordPress Chinese 中文文档
wordpress.org.cn
目录 |
Description
The get_bloginfo() function returns information about your blog which can then be used elsewhere in your PHP code. This function, as well as bloginfo(), can also be used to display your blog information.
Usage
%%% ?php $bloginfo = get_bloginfo( $show ); ? %%%
Parameters
- tt$show/tt
- (string) (Optional) Keyword naming the information you want.
- Default: namenoinclude
div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9
Notes
This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre 已侦测回归模板: Template:Parameter
The usage of this template is below: prenowiki已侦测回归模板: Template:Parameter/nowiki/pre Let's take a closer look at the parameters..
- name
- The name of the parameter.
- datatype
- The datatype that should be given for this parameter when called.
- string
- integer
- boolean
- mixed
- description
- A short description of the parameter.
- importance
- Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
- required
- optional
- default
- If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.
wordpress.org.cn /div /noinclude
If you omit this parameter or pass any value besides those below, the function returns the Weblog title.
- name
- (default) returns the Weblog title set in Administration rarr; Settings rarr; General. This data is retrieved from the ttblogname/tt record in the wp_options table.
- description
- the Tagline set in Administration rarr; Settings rarr; General. This data is retrieved from the ttblogdescription/tt record in the wp_options table.
- url
- strikehome/strike (deprecated)
- strikesiteurl/strike (deprecated)
- the Blog address (URI) is the URL for your blog's web site address and is set in Administration rarr; Settings rarr; General. This data is retrieved from the tthome/tt record in the wp_options table.
- wpurl
- the WordPress address (URI) is the URL for your WordPress installation and is set in Administration rarr; Settings rarr; General. This data is retrieved from the ttsiteurl/tt record in the wp_options table.
- rdf_url
- URL for the blog's RDF/RSS 1.0 feed (/feed/rfd).
- rss_url
- URL for the blog's RSS 0.92 feed (/feed/rss).
- rss2_url
- URL for the blog's RSS 2.0 feed (/feed).
- atom_url
- URL for the blog's Atom feed (/feed/atom).
- comments_rss2_url
- URL for the blog's comments RSS 2.0 feed (/comments/feed).
- pingback_url
- URL for Pingback XML-RPC file (xmlrpc.php).
- stylesheet_url
- URL for primary CSS file (usually style.css) of the active theme.
- stylesheet_directory
- URL of the stylesheet directory of the active theme. (Was a local path in earlier WordPress versions.)
- template_directory
- template_url
- URL of the active theme's directory. (tttemplate_directory/tt was a local path before 2.6; see get_theme_root() and get_template() for hackish alternatives.) Within child themes, both get_bloginfo(template_url) and get_template() will return the emparent/em theme directory.
- admin_email
- The Administrator's E-mail address set in Administration rarr; Settings rarr; General. This data is retrieved from the ttadmin_email/tt record in the wp_options table.
- charset
- The Encoding for pages and feeds set in Administration rarr; Settings rarr; Reading. This data is retrieved from the ttblog_charset/tt record in the wp_options table.
- version
- Version of WordPress your blog uses. This data is the value of var$wp_version/var variable set in wp-includes/version.php.
- html_type
- Content-Type of WordPress HTML pages (default: tttext/html/tt); stored in the tthtml_type/tt record in the wp_options table. Themes and plugins can override the default value by using the ttpre_option_html_type/tt filter (see this section of the Codex for more information on pre_option_ filters).
Examples
Default Usage
The default usage assigns your blog's title to the variable $blog_title.
pre
?php $blog_title = get_bloginfo(); ?
/pre
Blog Title
This example assign your blog's title to the variable $blog_title. This returns the same result as the default usage.
pre
?php $blog_title = get_bloginfo('name'); ?
/pre
Blog Tagline
Using this example:
pre
?php echo 'Your Blog Tagline is: ' . get_bloginfo ( 'description' ); ?br /
/pre
results in this being displayed on your blog:
pre
Your Blog Tagline is: All things WordPress
/pre
Template Directory
Returns template directory URL to the active theme.
Example output
From version 2.7. On host ttexample/tt, the Blog address (URL) is shown at tthttp://example/home/tt, and the WordPress address (URL) is installed at tthttp://example/home/wp/tt.
Note that directory URLs are missing trailing slashes.
pre 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 /pre
Source File
!-- Need links to current source code files -- ttget_bloginfo()/tt is located in ttwp-includes/general-template.php/tt.
Related
includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude
Description
This Template is used by Codex:Template Messages.
Usage
pre 已侦测回归模板: Template:Message /pre
Result
已侦测回归模板: Template:Message
/noinclude

