- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/get theme root
提供: WordPress Codex 日本語版
目次
説明
テーマディレクトリの絶対パスを取得します。この時、最後のスラッシュは記載されません。
使用法
<?php get_theme_root(); ?>
パラメーター
- $stylesheet_or_template
- (string) (必須) テーマのスタイルシートまたはテンプレート名
- 初期値: なし
戻り値
- (string)
- テーマディレクトリの絶対パス。ただし、最後のスラッシュは記載されません。
使用例
Number of Subdirectories in Themes Directory
The function below informs about the number of subdirectories in the themes directory. Note that this doesn't necessarily match the number of themes recognized by WordPress.
<?php function display_themes_subdirs_count_info() $theme_root = get_theme_root(); $files_array = glob("$theme_root/*", GLOB_ONLYDIR); echo "There are " . count($files_array) . " subdirectories in the " . $theme_root " directory"; } ?>
Example output:
There are 5 subdirectories in the /home/user/public_html/wp-content/themes directory.
注
- Uses: apply_filters() to apply the theme_root filters on the retrieved path.
改訂履歴
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 (最新版との差分)
関数リファレンス、テンプレートタグ目次もご覧ください。