- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/get theme root」の版間の差分
提供: WordPress Codex 日本語版
< 関数リファレンス
(和訳完了。) |
細 (→関連項目) |
||
65行目: | 65行目: | ||
{{Tag Footer}} | {{Tag Footer}} | ||
− | |||
− | |||
− |
2015年5月18日 (月) 09:17時点における最新版
テーマディレクトリの絶対パスを取得します。この時、最後のスラッシュは記載されません。
使用法
<?php get_theme_root(); ?>
パラメーター
- $stylesheet_or_template
- (string) (必須) テーマのスタイルシートまたはテンプレート名
- 初期値: なし
戻り値
- (string)
- テーマディレクトリの絶対パス。ただし、最後のスラッシュは記載されません。
使用例
テーマディレクトリ内のサブディレクトリ数
テーマディレクトリ内のサブディレクトリ数を引用する関数です。これは WordPress が認識していると一致している必要はありません。
<?php function display_themes_subdirs_count_info() $theme_root = get_theme_root(); $files_array = glob("$theme_root/*", GLOB_ONLYDIR); echo . $theme_root " ディレクトリには" . count($files_array) . "個のサブディレクトリがあります。"; } ?>
出力例:
/home/user/public_html/wp-content/themes ディレクトリには 5 個のサブディレクトリがあります。
注
- 引用されたパスに theme_root フィルターを適用させるために、 apply_filters() を用います。
改訂履歴
1.5.0 にて導入されました。
ソースファイル
get_theme_root() は wp-includes/theme.php
にあります。
関連項目
テーマのパス: get_template(), get_template_directory(), get_template_directory_uri(), get_theme_roots() /en, get_theme_root(), get_theme_root_uri() /en, get_stylesheet() /en, get_stylesheet_uri(), get_stylesheet_directory(), get_stylesheet_directory_uri(), get_bloginfo()
最新英語版: WordPress Codex » Function Reference/get theme root (最新版との差分)
関数リファレンス、テンプレートタグ目次もご覧ください。