• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「テンプレートタグ/get bloginfo」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(1 版)
(最新英語版( 17:57, 15 February 2013 Adamcolon 版)を反映。未翻訳です。)
1行目: 1行目:
* 書式: <?php get_bloginfo('show'); ?>
+
{{NeedTrans}}
* 説明: ブログに関するさまざまな情報をPHPの値として返す。
+
* 位置: ループ内・外
+
* 引数:
+
** show (規定値)- 出力する情報の内容。取れる値は [[テンプレートタグ/bloginfo |bloginfo()]] タグに加え、以下の2つ。
+
*** home(「url」引数と同じく、ブログのサイトURL)
+
*** siteurl(「url」引数と同じく、ブログのサイトURL)
+
*** language(ブログの文字コード。例: ja)
+
  
[[en:Template Tags/get_bloginfo]]
+
<div id="Description">
 +
== 説明 ==
 +
 
 +
The [[テンプレートタグ/get_bloginfo|get_bloginfo()]] function returns information about your site which can then be used elsewhere in your PHP code. This function, as well as [[テンプレートタグ/bloginfo|bloginfo()]], can also be used to display your site information.
 +
 
 +
</div>
 +
 
 +
<div id="Usage">
 +
== 使い方 ==
 +
 
 +
<?php $bloginfo = get_bloginfo( $show, $filter ); ?>
 +
 
 +
</div>
 +
 
 +
<div id="Parameters">
 +
== パラメータ ==
 +
 
 +
{{Parameter|$show|string|Keyword naming the information you want.|Optional|name}}
 +
 
 +
:* '<tt>'''name'''</tt>' - Returns the '<tt>Site Title</tt>' set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the '<tt>blogname</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]].
 +
:* '<tt>'''description'''</tt>' - Returns the '<tt>Tagline</tt>' set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the '<tt>blogdescription</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]].
 +
:* '<tt>'''wpurl'''</tt>' - Returns the '<tt>WordPress address (URL)</tt>' set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the '<tt>siteurl</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]]. Consider using [[テンプレートタグ/site url | site_url()]] instead, especially for multi-site configurations using paths instead of subdomains (it will return the root site not the current sub-site).
 +
:* '<tt>'''siteurl'''</tt>' / '<tt>'''home (note this is deprecated! from version 2.2)'''</tt>' / '<tt>'''url'''</tt>' - Returns the '<tt>Site address (URL)</tt>' set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the '<tt>home</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]]. Consider using [[テンプレートタグ/home url | home_url()]] instead.
 +
:* '<tt>'''admin_email'''</tt>' - Returns the '<tt>E-mail address</tt>' set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the '<tt>admin_email</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]].
 +
:* '<tt>'''charset'''</tt>' - Returns the '<tt>Encoding for pages and feeds</tt>' set in [[Administration_Panels#Reading|Settings]] > [[Settings_Reading_SubPanel|Reading]]. This data is retrieved from the '<tt>blog_charset</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]].
 +
:* '<tt>'''version'''</tt>' - Returns the WordPress Version you use. This data is retrieved from the '<tt>$wp_version</tt>' variable set in {{Trac|wp-includes/version.php}}.
 +
:* '<tt>'''html_type'''</tt>' - Returns the Content-Type of WordPress HTML pages (default: <tt>text/html</tt>). This data is retrieved from the '<tt>html_type</tt>' record in the [[データベース概要#Table:_wp_options|wp_options table]]. Themes and plugins can override the default value using the <tt>[[プラグイン_API/フィルターフック一覧|pre_option_html_type]]</tt> filter.
 +
:* '<tt>'''text_direction'''</tt>' - Returns the Text Direction of WordPress HTML pages.  Consider using [[関数リファレンス/is_rtl | is_rtl()]] /[[:en:Function Reference/is_rtl|en]] instead.
 +
:* '<tt>'''language'''</tt>' - Returns the language of WordPress.
 +
:* '<tt>'''stylesheet_url'''</tt>' - Returns the primary [[Glossary#CSS|CSS]] (usually ''style.css'') file URL of the active theme. Consider using [[関数リファレンス/get_stylesheet_uri | get_stylesheet_uri()]] /[[:en:Function Reference/get_stylesheet_uri|en]] instead.
 +
:* '<tt>'''stylesheet_directory'''</tt>' - Returns the stylesheet directory URL of the active theme. (Was a local path in earlier WordPress versions.) Consider using [[関数リファレンス/get_stylesheet_directory_uri | get_stylesheet_directory_uri()]] instead.
 +
:* '<tt>'''template_url'''</tt>' / '<tt>'''template_directory'''</tt>' - URL of the active theme's directory ('<tt>template_directory</tt>' was a local path before [[Version 2.6|2.6]]; see [[関数リファレンス/get_theme_root|get_theme_root()]] /[[:en:Function Reference/get_theme_root|en]] and [[関数リファレンス/get_template|get_template()]] /[[:en:Function Reference/get_template|en]] for hackish alternatives.)  Within child themes, both get_bloginfo('template_url') and get_template() will return the <em>parent</em> theme directory. Consider using [[関数リファレンス/get_template_directory_uri | get_template_directory_uri()]] instead (for the parent template directory) or [[関数リファレンス/get_stylesheet_directory_uri | get_stylesheet_directory_uri()]] (for the child template directory).
 +
:* '<tt>'''pingback_url'''</tt>' - Returns the Pingback XML-RPC file URL (''xmlrpc.php'').
 +
:* '<tt>'''atom_url'''</tt>' - Returns the Atom feed URL (''/feed/atom'').
 +
:* '<tt>'''rdf_url'''</tt>' - Returns the RDF/RSS 1.0 feed URL (''/feed/rfd'').
 +
:* '<tt>'''rss_url'''</tt>' - Returns the RSS 0.92 feed URL (''/feed/rss'').
 +
:* '<tt>'''rss2_url'''</tt>' - Returns the RSS 2.0 feed URL (''/feed'').
 +
:* '<tt>'''comments_atom_url'''</tt>' - Returns the comments Atom feed URL (''/comments/feed'').
 +
:* '<tt>'''comments_rss2_url'''</tt>' - Returns the comments RSS 2.0 feed URL (''/comments/feed'').
 +
 
 +
{{Parameter|$filter|string|Keyword specifying how to filter what is retrivied.|Optional|raw}}
 +
 
 +
:* '<tt>'''Display'''</tt>' - Passes the value of  '<tt>$show</tt>' through  [[関数リファレンス/wptexturize | wptexturize()]] /[[:en:Function Reference/wptexturize|en]] function before returning it to caller.
 +
:* '<tt>'''raw'''</tt>' - Returns the value of  '<tt>$show</tt>' as is.
 +
 
 +
</div>
 +
 
 +
<div id="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>
 +
 
 +
===Network Tagline ===
 +
 
 +
Using this example, you can obtain the name and description for the network home:
 +
 
 +
<pre>
 +
<?php
 +
switch_to_blog(1);
 +
$site_title = get_bloginfo( 'name' );
 +
$site_url = network_site_url( '/' );
 +
$site_description = get_bloginfo( 'description' );
 +
restore_current_blog();
 +
echo 'The Network Home URL is: ' . $site_url;
 +
echo 'The Network Home Name is: ' . $site_title;
 +
echo 'The Network Home Tagline is: ' . $site_description; 
 +
?>
 +
</pre>
 +
 
 +
results in this being displayed on your blog:
 +
 
 +
<pre>
 +
The Network Home URL is: http://example.com/
 +
The Network Home Name is: Example
 +
The Network Home Tagline is: The example site
 +
</pre>
 +
 
 +
=== Template Directory ===
 +
Returns template directory URL to the active theme.
 +
 
 +
=== Example output ===
 +
 
 +
From version 2.7. On host <tt>example</tt>, the [[Settings_General_SubPanel|Blog address (URL)]] is shown at <tt>http://www.example.com/home</tt>, and the [[Settings_General_SubPanel|WordPress address (URL)]] is installed at <tt>http://www.example.com/home/wp</tt>.
 +
 
 +
Note that directory URLs are missing trailing slashes.
 +
 
 +
<pre>
 +
admin_email          = admin@example.com
 +
atom_url            = http://www.example.com/home/feed/atom
 +
charset              = UTF-8
 +
comments_atom_url    = http://www.example.com/home/comments/feed/atom
 +
comments_rss2_url    = http://www.example.com/home/comments/feed
 +
description          = Just another WordPress blog
 +
home                = http://www.example.com/home (DEPRECATED! use url option instead)
 +
html_type            = text/html
 +
language            = en-US
 +
name                = Testpilot
 +
pingback_url        = http://www.example.com/home/wp/xmlrpc.php
 +
rdf_url              = http://www.example.com/home/feed/rdf
 +
rss2_url            = http://www.example.com/home/feed
 +
rss_url              = http://www.example.com/home/feed/rss
 +
siteurl              = http://www.example.com/home (DEPRECATED! use url option instead)
 +
stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo
 +
stylesheet_url      = http://www.example.com/home/wp/wp-content/themes/largo/style.css
 +
template_directory  = http://www.example.com/home/wp/wp-content/themes/largo
 +
template_url        = http://www.example.com/home/wp/wp-content/themes/largo
 +
text_direction      = ltr
 +
url                  = http://www.example.com/home
 +
version              = 3.5
 +
wpurl                = http://www.example.com/home/wp
 +
</pre>
 +
 
 +
</div>
 +
 
 +
<div id="Source File">
 +
== ソースファイル ==
 +
<tt>get_bloginfo()</tt> は <tt>{{Trac|wp-includes/general-template.php}}</tt> にあります。
 +
 
 +
</div>
 +
 
 +
<div id="Related">
 +
== 関連 ==
 +
* [[テンプレートタグ/bloginfo|<tt>bloginfo()</tt>]]
 +
* [[Function_Reference/get_admin_url|<tt>get_admin_url()</tt>]] /[[:en:Function Reference/admin_url|en]]
 +
 
 +
{{原文|Function Reference/get_bloginfo|127412}}<!-- 17:57, 15 February 2013 Adamcolon 版 -->
 +
</div>
 +
 
 +
{{Tag Footer}}
 +
 
 +
[[Category:テンプレートタグ]]

2013年2月22日 (金) 21:55時点における版

このページ「テンプレートタグ/get bloginfo」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

説明

The get_bloginfo() function returns information about your site which can then be used elsewhere in your PHP code. This function, as well as bloginfo(), can also be used to display your site information.

使い方

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

パラメータ

$show
string) (Optional) Keyword naming the information you want.
初期値: name
  • 'name' - Returns the 'Site Title' set in Settings > General. This data is retrieved from the 'blogname' record in the wp_options table.
  • 'description' - Returns the 'Tagline' set in Settings > General. This data is retrieved from the 'blogdescription' record in the wp_options table.
  • 'wpurl' - Returns the 'WordPress address (URL)' set in Settings > General. This data is retrieved from the 'siteurl' record in the wp_options table. Consider using site_url() instead, especially for multi-site configurations using paths instead of subdomains (it will return the root site not the current sub-site).
  • 'siteurl' / 'home (note this is deprecated! from version 2.2)' / 'url' - Returns the 'Site address (URL)' set in Settings > General. This data is retrieved from the 'home' record in the wp_options table. Consider using home_url() instead.
  • 'admin_email' - Returns the 'E-mail address' set in Settings > General. This data is retrieved from the 'admin_email' record in the wp_options table.
  • 'charset' - Returns the 'Encoding for pages and feeds' set in Settings > Reading. This data is retrieved from the 'blog_charset' record in the wp_options table.
  • 'version' - Returns the WordPress Version you use. This data is retrieved from the '$wp_version' variable set in wp-includes/version.php.
  • 'html_type' - Returns the Content-Type of WordPress HTML pages (default: text/html). This data is retrieved from the 'html_type' record in the wp_options table. Themes and plugins can override the default value using the pre_option_html_type filter.
  • 'text_direction' - Returns the Text Direction of WordPress HTML pages. Consider using is_rtl() /en instead.
  • 'language' - Returns the language of WordPress.
  • 'stylesheet_url' - Returns the primary CSS (usually style.css) file URL of the active theme. Consider using get_stylesheet_uri() /en instead.
  • 'stylesheet_directory' - Returns the stylesheet directory URL of the active theme. (Was a local path in earlier WordPress versions.) Consider using get_stylesheet_directory_uri() instead.
  • 'template_url' / 'template_directory' - URL of the active theme's directory ('template_directory' was a local path before 2.6; see get_theme_root() /en and get_template() /en for hackish alternatives.) Within child themes, both get_bloginfo('template_url') and get_template() will return the parent theme directory. Consider using get_template_directory_uri() instead (for the parent template directory) or get_stylesheet_directory_uri() (for the child template directory).
  • 'pingback_url' - Returns the Pingback XML-RPC file URL (xmlrpc.php).
  • 'atom_url' - Returns the Atom feed URL (/feed/atom).
  • 'rdf_url' - Returns the RDF/RSS 1.0 feed URL (/feed/rfd).
  • 'rss_url' - Returns the RSS 0.92 feed URL (/feed/rss).
  • 'rss2_url' - Returns the RSS 2.0 feed URL (/feed).
  • 'comments_atom_url' - Returns the comments Atom feed URL (/comments/feed).
  • 'comments_rss2_url' - Returns the comments RSS 2.0 feed URL (/comments/feed).
$filter
string) (Optional) Keyword specifying how to filter what is retrivied.
初期値: raw
  • 'Display' - Passes the value of '$show' through wptexturize() /en function before returning it to caller.
  • 'raw' - Returns the value of '$show' as is.

用例

Default Usage

The default usage assigns your blog's title to the variable $blog_title.

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

Blog Title

This example assign your blog's title to the variable $blog_title. This returns the same result as the default usage.

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

Blog Tagline

Using this example:

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

results in this being displayed on your blog:

 Your Blog Tagline is: All things WordPress

Network Tagline

Using this example, you can obtain the name and description for the network home:

 <?php
 switch_to_blog(1);
 $site_title = get_bloginfo( 'name' );
 $site_url = network_site_url( '/' );
 $site_description = get_bloginfo( 'description' );
 restore_current_blog();
 echo 'The Network Home URL is: ' . $site_url;
 echo 'The Network Home Name is: ' . $site_title;
 echo 'The Network Home Tagline is: ' . $site_description;  
?>

results in this being displayed on your blog:

 The Network Home URL is: http://example.com/
 The Network Home Name is: Example
 The Network Home Tagline is: The example site

Template Directory

Returns template directory URL to the active theme.

Example output

From version 2.7. On host example, the Blog address (URL) is shown at http://www.example.com/home, and the WordPress address (URL) is installed at http://www.example.com/home/wp.

Note that directory URLs are missing trailing slashes.

admin_email          = admin@example.com
atom_url             = http://www.example.com/home/feed/atom
charset              = UTF-8
comments_atom_url    = http://www.example.com/home/comments/feed/atom
comments_rss2_url    = http://www.example.com/home/comments/feed
description          = Just another WordPress blog
home                 = http://www.example.com/home (DEPRECATED! use url option instead)
html_type            = text/html
language             = en-US
name                 = Testpilot
pingback_url         = http://www.example.com/home/wp/xmlrpc.php
rdf_url              = http://www.example.com/home/feed/rdf
rss2_url             = http://www.example.com/home/feed
rss_url              = http://www.example.com/home/feed/rss
siteurl              = http://www.example.com/home (DEPRECATED! use url option instead)
stylesheet_directory = http://www.example.com/home/wp/wp-content/themes/largo
stylesheet_url       = http://www.example.com/home/wp/wp-content/themes/largo/style.css
template_directory   = http://www.example.com/home/wp/wp-content/themes/largo
template_url         = http://www.example.com/home/wp/wp-content/themes/largo
text_direction       = ltr
url                  = http://www.example.com/home
version              = 3.5
wpurl                = http://www.example.com/home/wp

ソースファイル

get_bloginfo()wp-includes/general-template.php にあります。


関数リファレンステンプレートタグ目次もご覧ください。