WordPress
get_bloginfo()
サーチ…
前書き
現在のサイトに関する情報を取得します。
構文
- get_bloginfo($ show、$ filter)
パラメーター
| パラメータ | 詳細 |
|---|---|
| $ show | (文字列)取得するサイト設定情報。 |
| $ filter | (文字列)フィルタリングされた値を返すかどうかに関する指定。 |
備考
$ show
| 値 | 説明 | 例 |
|---|---|---|
| 'name'(デフォルト) | ウェブサイト名 | 'Matt Mullenweg' |
| 'description' | サイトのタグライン | 'Just another WordPress site' |
| 'wpurl' | WordPressインストールのURL。 site_url()関数と同じです。 | 'http://example.com' 、 'http://localhost/wordpress' |
| 'url' | サイトのURL。 home_url()関数と同じです。 | 'http://example.com' 、 'http://localhost/wordpress' |
| 'admin_email' | メイン管理者のメールアドレス | '[email protected]' |
| 'charset' | ページとフィードの文字エンコーディング | 'UTF-8' |
| 'バージョン' | 現在のバージョンのWordPressインストール | '4.5' |
| 'html_type' | HTMLのcontent-type値 | 'text/html' |
| 'text_direction' | サイトの言語によって決定されるテキストの方向 | 'ltr' |
| '言語' | ISO 639-1ベースの言語コード | 'en-US' |
| 'stylesheet_url' | 有効化されたテーマのスタイルシートのURL。値の優先度: 子テーマ »親テーマ。 | 'http://example.com/wp-content/themes/twentysixteen/style.css' |
| 'stylesheet_directory' | アクティブ化されたテーマのリソースの場所。値の優先度: 子テーマ »親テーマ。 | 'http://example.com/wp-content/themes/twentysixteen' |
| 'template_url' | アクティブ化されたテーマのURLディレクトリ。値の優先度: 親テーマ »子テーマ。 | 'http://example.com/wp-content/themes/twentysixteen' |
| 'template_directory' | 'template_url'同じです。 | |
| 'pingback_url' | Pingback XML-RPCファイル | 'http://example/xmlrpc.php' |
| 'atom_url' | AtomフィードのURL | 'http://example/feed/atom/' |
| 'rdf_url' | RDF / RSS 1.0のフィードURL | 'http://example/feed/rdf/' |
| 'rss_url' | RSS 0.92フィードURL | 'http://example/feed/rss/' |
| 'rss2_url' | RSS 2.0のフィードURL | 'http://example/feed/' |
| 'comments_atom_url' | コメントAtomフィードのURL | 'http://example/comments/feed/atom/' |
| 'サイトのURL' | (廃止予定)代わりに 'url'を使用 | |
| 'ホーム' | (廃止予定)代わりに 'url'を使用 |
$ filter
| 値 | 説明 | 例 |
|---|---|---|
| 'raw'(デフォルト) | フィルタは適用されません | 生データ |
| '表示' | $showが'url' 、 'directory' 、 'home'いずれでもない場合、フィルタは戻り値に適用されます。 | フィルタリングされたデータ |
サイトのタイトルを取得する
<?php echo get_bloginfo( 'name' ); ?>
または
<?php echo get_bloginfo(); ?>
出力
Matt Mullenweg
これらのサンプル設定に基づいて
サイトのタグラインを取得する
<?php echo get_bloginfo( 'description' ); ?>
出力
Just another WordPress site
これらのサンプル設定に基づいて
アクティブなテーマのURLを取得する
<?php echo esc_url( get_bloginfo( 'stylesheet_directory' ) ); ?>
出力
http://example.com/wp-content/themes/twentysixteen
代替案
内部的には、 get_bloginfo( 'stylesheet_directory' )はget_stylesheet_directory_uri()呼び出します。代わりにそれを使用することができます:
<?php echo esc_url( get_stylesheet_directory_uri() ); ?>
多くの開発者は、 get_bloginfo()との間で一貫性のない命名規則のために、これらの専用関数を使用することを好みます。たとえば、 get_stylesheet_directory()は子のテーマパスを返します。しかし、前の例で示したように、 get_bloginfo( 'stylesheet_directory' )は子テーマのURLを返します。代わりにget_stylesheet_directory_uri()を使用すると、パスまたはURLを取得しているかどうかを混乱させる可能性が少なくなります。
サイトのURLを取得する
<?php echo esc_url(get_bloginfo('url')); ?>
またはサブページにリンクする必要がある場合
<?php echo esc_url(get_bloginfo('url') . '/some-sub-page'); ?>
サイト管理者の電子メールアドレスを取得する
get_bloginfo関数を使用して、サイト管理者の電子メールアドレスを取得できます。
<?php echo get_bloginfo('admin_email'); ?>
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow

