- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/get stylesheet directory uri
提供: WordPress Codex 日本語版
< 関数リファレンス
この項目「関数リファレンス/get stylesheet directory uri」は、翻訳チェック待ちの項目です。加筆、訂正などを通して、Codex ドキュメンテーションにご協力下さい。
説明
テーマまたは子テーマの スタイルシート ディレクトリの URI を取得する。SSL が存在するかチェックする。
注意: 末尾にスラッシュ( / )は含まれません。
この関数は、適切な形式のURIを返します。つまり、(http:// or https:// 等の完全な形の)ウェブアドレスです。リンクや、追加スタイルシートの参照、あるいは最も良く使うであろう画像の参照に使用するのに適しています。
子テーマを使用している場合、子テーマのディレクトリの URI を返します。 親テーマのディレクトリを取得するには get_template_directory_uri() を使用してください。
ローカルファイルへのリンクが欲しい場合は、get_stylesheet_directory()/enを使用してください。
使い方
URI を使う場合
<?php get_stylesheet_directory_uri(); ?>
URI を出力する場合
<?php echo get_stylesheet_directory_uri(); ?>
パラメータ
なし
戻り値
- uri (文字列)
- スタイルシートのあるディレクトリ URI
用例
Image (HTML)
<img src="<?php echo get_stylesheet_directory_uri() ?>/images/aternus.png" alt="" title="" width="" height="" />
注
- apply_filters() を使用。スタイルシートパスおよび名前の箇所で 'stylesheet_directory_uri' フィルタを呼び出す。
- get_stylesheet()/en を使用。
- get_theme_root()/en を使用。
変更履歴
- Version 1.5 にて導入されました。
ソースファイル
get_stylesheet_directory_uri() は wp-includes/theme.php
にあります。
最新英語版: WordPress Codex » Function Reference/get_stylesheet_directory_uri (最新版との差分)
関連
http://gatespace.jp/2013/02/22/underscores04/#sec3 -GateSpace スターターテーマ _s を使ってWordPressのテーマをつくる(ファイルパスとブログ情報編)
関数リファレンス、テンプレートタグ目次もご覧ください。