0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

wordpress関数〜ディレクト編

Last updated at Posted at 2022-10-13

ホームディレクトリ

/(スラッシュ)は含まれない。
esc_url()は危険な文字をエスケープしてくれる。

<?php echo esc_url(home_url(‘sample’));?>
https://example.com/sample

<?php echo esc_url(home_url( ));?>
https://example.com

テーマ ディレクトリの絶対パス・URLを取得

絶対パス
<?php echo get_theme_root(); ?>
/home/user/public_html/wp-content/themes

URL
<?php echo get_theme_root_uri(); ?>
https://example.com/wp-content/themes

親テーマまたはテーマ ディレクトリの絶対パス・URLを取得

絶対パス
<?php echo get_template_directory(); ?>
/home/user/public_html/wp-content/themes/my_theme

URL
<?php echo get_template_directory_uri(); ?>
https://example.com/wp-content/themes/my_theme

子テーマ ディレクトリの絶対パス・URLを取得

絶対パス
<?php echo get_stylesheet_directory(); ?>
/home/user/public_html/wp-content/themes/my_theme

URI
<?php echo get_stylesheet_directory_uri(); ?>
https://example.com/wp-content/themes/my_theme
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?