get_stylesheet_directory

Sponsored Link

現在のテーマのスタイルシートディレクトリーパスを取得します。

URLではなく、絶対サーバーパスを返すことに注意してください(例:/var/www/html/myblog/wp-content/themes/my_theme)。このように、これは次のようなファイルレベルの操作に最も適しています:

require_once(get_stylesheet_directory() . '/my_include.php');

WebフレンドリーなURLをしたい場合、
このようなリンク或いは画像の参照内に使用されるであろう1つとして、
代わりにget_stylesheet_directory_uri()を使用してください。

Sponsored Link

Retrieve stylesheet directory path for current theme.

Note that this returns an absolute server path (eg: /var/www/html/myblog/wp-content/themes/my_theme), not a URI. As such, it’s most suitable for file-level operations, such as:
require_once(get_stylesheet_directory() . ‘/my_include.php’);

If you want a web-friendly URI, such as one that would be used in a link or a reference to an image, use get_stylesheet_directory_uri() instead.

get_stylesheet_directoryのファンクションタグ使用方法

<?php get_stylesheet_directory() ?>

get_stylesheet_directoryのパラメーター

None.

戻り値

(string)
現在のテーマディレクトリーパスです。

(string)
Path to current theme directory.

注釈

  • 用途: apply_filters()は、スタイルシートパスと名前に’stylesheet_directory’を呼び出します。
  • Uses: get_stylesheet()
  • Uses: get_theme_root()
  • 子テーマが使用されている場合、親テーマディレクトリがない場合に返すディレクトリーです。(親ディレクトリにしたい場合、代わりにget_template_directory()を使用します。)
  • Uses: apply_filters() Calls ‘stylesheet_directory’ filter on stylesheet path and name.
  • Uses: get_stylesheet()
  • Uses: get_theme_root()
  • In the event a child theme is being used, that is the directory that will be returned, not the parent theme directory (use get_template_directory() instead if you want the parent directory)

変更ログ

Since: 1.5.0

ソースファイル

get_stylesheet_directory()は、wp-includes/theme.php内に位置しています。

get_stylesheet_directory() is located in wp-includes/theme.php.

Sponsored Link