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

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

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

提供: WordPress Codex 日本語版
移動先: 案内検索
(出力例)
(パラメータ)
21行目: 21行目:
 
</div>
 
</div>
  
{{Parameter|$show|string|Keyword naming the information you want.|Optional|name}}
+
{{Parameter|$show|string|Keyword naming the information you want.|オプション|name}}
  
 
:* ''''name'''' - Returns the "Site Title" set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the "blogname" record in the [[データベース概要#Table:_wp_options|wp_options table]].
 
:* ''''name'''' - Returns the "Site Title" set in [[Administration_Panels#General|Settings]] > [[Settings_General_SubPanel|General]]. This data is retrieved from the "blogname" record in the [[データベース概要#Table:_wp_options|wp_options table]].
32行目: 32行目:
 
:* ''''html_type'''' - Returns the Content-Type of WordPress HTML pages (default: "text/html"). This data is retrieved from the "html_type" record in the [[データベース概要#Table:_wp_options|wp_options table]]. Themes and plugins can override the default value using the <tt>[[Plugin_API/Filter_Reference|pre_option_html_type]]</tt> filter.
 
:* ''''html_type'''' - Returns the Content-Type of WordPress HTML pages (default: "text/html"). This data is retrieved from the "html_type" record in the [[データベース概要#Table:_wp_options|wp_options table]]. Themes and plugins can override the default value using the <tt>[[Plugin_API/Filter_Reference|pre_option_html_type]]</tt> filter.
 
:* ''''text_direction'''' - Returns the Text Direction of WordPress HTML pages.  Consider using [[関数リファレンス/is_rtl | is_rtl()]] instead.
 
:* ''''text_direction'''' - Returns the Text Direction of WordPress HTML pages.  Consider using [[関数リファレンス/is_rtl | is_rtl()]] instead.
:* ''''language'''' - Returns the language of WordPress.
+
:* ''''language'''' - WordPressの言語を返す。
 
:* ''''stylesheet_url'''' - Returns the primary [[Glossary#CSS|CSS]] (usually ''style.css'') file URL of the active theme. Consider using [[関数リファレンス/get_stylesheet_uri | get_stylesheet_uri()]] instead.
 
:* ''''stylesheet_url'''' - Returns the primary [[Glossary#CSS|CSS]] (usually ''style.css'') file URL of the active theme. Consider using [[関数リファレンス/get_stylesheet_uri | get_stylesheet_uri()]] 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 | get_stylesheet_directory_uri()]] 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 | get_stylesheet_directory_uri()]] instead.
 
:* ''''template_url'''' / ''''template_directory'''' - URL of the active theme's directory ('template_directory' was a local path before [[Version 2.6|2.6]]; see [[関数リファレンス/get_theme_root|get_theme_root()]] and [[関数リファレンス/get_template|get_template()]] 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).
 
:* ''''template_url'''' / ''''template_directory'''' - URL of the active theme's directory ('template_directory' was a local path before [[Version 2.6|2.6]]; see [[関数リファレンス/get_theme_root|get_theme_root()]] and [[関数リファレンス/get_template|get_template()]] 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).
:* ''''pingback_url'''' - Returns the Pingback XML-RPC file URL (''xmlrpc.php'').
+
:* ''''pingback_url'''' - Pingback XML-RPC file URL を返す。 (''xmlrpc.php'')
:* ''''atom_url'''' - Returns the Atom feed URL (''/feed/atom'').
+
:* ''''atom_url'''' - Atom feed URL を返す。 (''/feed/atom'')
:* ''''rdf_url'''' - Returns the RDF/RSS 1.0 feed URL (''/feed/rfd'').
+
:* ''''rdf_url'''' -RDF/RSS 1.0 feed URL を返す。(''/feed/rfd'')
:* ''''rss_url'''' - Returns the RSS 0.92 feed URL (''/feed/rss'').
+
:* ''''rss_url'''' - RSS 0.92 feed URL を返す。 (''/feed/rss'')
:* ''''rss2_url'''' - Returns the RSS 2.0 feed URL (''/feed'').
+
:* ''''rss2_url'''' - RSS 2.0 feed URL を返す。 (''/feed'')
:* ''''comments_atom_url'''' - Returns the comments Atom feed URL (''/comments/feed'').
+
:* ''''comments_atom_url'''' - Atom feedコメントの URL を返す。 (''/comments/feed'')
:* ''''comments_rss2_url'''' - Returns the comments RSS 2.0 feed URL (''/comments/feed'').
+
:* ''''comments_rss2_url'''' - RSS 2.0 feedコメントの URL を返す。 (''/comments/feed'')
:* ''''siteurl'''' - Deprecated since version 2.2. Use [[関数リファレンス/home_url | home_url()]], or get_bloginfo('url').
+
:* ''''siteurl'''' - バージョン2.2にて非推奨。 [[関数リファレンス/home_url | home_url()]], または get_bloginfo('url')をお使いください。
:* ''''home'''' - Deprecated since version 2.2. Use [[関数リファレンス/home_url | home_url()]], or get_bloginfo('url').
+
:* ''''home'''' - バージョン2.2にて非推奨。 [[関数リファレンス/home_url | home_url()]], または get_bloginfo('url')をお使いください。
  
 
{{Parameter|$filter|string|Keyword specifying how to filter what is retrieved.|Optional|raw}}
 
{{Parameter|$filter|string|Keyword specifying how to filter what is retrieved.|Optional|raw}}

2015年6月30日 (火) 08:53時点における版

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

説明

この関数は、他の場所でPHPのコードで使用することができ、サイトに関する情報を返します。 この関数と同様に bloginfo()も、テンプレートファイル内の任意の場所で、サイト情報を表示するために使用できます。

使い方

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

パラメータ

$show
string) (オプション) 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).
  • 'url' - Returns the "Site address (URL)" set in Settings > General. This data is retrieved from the "home" record in the wp_options table. Equivalent to home_url().
  • '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() instead.
  • 'language' - WordPressの言語を返す。
  • 'stylesheet_url' - Returns the primary CSS (usually style.css) file URL of the active theme. Consider using get_stylesheet_uri() 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() and get_template() 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' - Pingback XML-RPC file URL を返す。 (xmlrpc.php)
  • 'atom_url' - Atom feed URL を返す。 (/feed/atom)
  • 'rdf_url' -RDF/RSS 1.0 feed URL を返す。(/feed/rfd)
  • 'rss_url' - RSS 0.92 feed URL を返す。 (/feed/rss)
  • 'rss2_url' - RSS 2.0 feed URL を返す。 (/feed)
  • 'comments_atom_url' - Atom feedコメントの URL を返す。 (/comments/feed)
  • 'comments_rss2_url' - RSS 2.0 feedコメントの URL を返す。 (/comments/feed)
  • 'siteurl' - バージョン2.2にて非推奨。 home_url(), または get_bloginfo('url')をお使いください。
  • 'home' - バージョン2.2にて非推奨。 home_url(), または get_bloginfo('url')をお使いください。
$filter
string) (Optional) Keyword specifying how to filter what is retrieved.
初期値: raw
  • 'display' - Passes the value of $show through the wptexturize() function before returning it to caller.
  • 'raw' - Returns the value of $show as is.

用例

デフォルトの例

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

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

ブログタイトル

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

テンプレートのディレクトリー

Returns template directory URL to the active theme.

出力例

Version 2.7 以降、example.com の場合、サイトアドレス (URL)http://www.example.com/home と表示され、WordPress アドレス (URL)http://www.example.com/home/wp にインストールされます。

ディレクトリーの URL は最後のスラッシュがないことに注意してください。

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


更新履歴

導入: 0.71

ソースファイル

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


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