WordPressで現在のテーマディレクトリーパスを取得する方法

ここでは、WordPressで現在のテーマディレクトリーパスを取得する方法について見ていきます。

get_template_directory_uri()

現在のテーマディレクトリーパスを取得するには「get_template_directory_uri()」を用います。

構文

<?php echo esc_url(get_template_directory_uri()); ?>

出力結果

http://localhost/Yagi-System-coding/wp-content/themes/Yagi-System-coding

まとめ

このように、「get_template_directory_uri()」を用いることで、現在のテーマのディレクトリパスを取得することができます。