パスを取得する

投稿日:2022-09-12 投稿者:PS カテゴリ:その他 タグ: , ,

関数戻り値備考
get_home_url()https://sample.comhome_url()
site_url()https://sample.com
admin_url()https://sample.com/wp-admin
includes_url()https://sample.com/wp-includes
content_url()https://sample.com/wp-content
plugins_url()https://sample.com/wp-content/plugins
plugin_dir_url(__FILE__)https://sample.com/wp-content/plugins/(pluginName)/(fileName)
plugin_dir_url(__DIR__)https://sample.com/wp-content/plugins/(pluginName)/(DirName)
get_theme_root()/home/sample/www/wp-content/themes
get_theme_file_uri()https://sample.com/wp-content/themes/sample
get_theme_file_path()/home/sample/www/wp-content/themes/sample
get_template_directry()/home/sample/www/wp-content/themes/sample
get_template_directry_uri()https://sample.com/wp-content/themes/sample
get_stylesheet_directry()/home/sample/www/wp-content/themes/sample
get_stylesheet_directry_uri()https://sample.com/wp-content/themes/sample
get_stylesheet_uri()https://sample.com/wp-content/themes/sample/style.css
wp_upload_dir()Array
get_bloginfo(‘wpurl’)https://sample.com
get_tag_link()https://sample.com/tag/(tag-slug)パーマリンク設定によってurlが決まる
ABSPATH/home/sample/www/
WP_CONTENT_DIR/home/sample/www/wp-content
WP_PLUGIN_DIR/home/sample/www/wp-content/plugins
<?php // 例 ... タグから URL を取得
$slug = 'iphone5';
$tag = get_term_by('slug', $slug, 'post_tag');  // slug名からタグの情報を得る
$link = get_tag_link($tag->term_id);            // タグのID から URL を得る
  • get_term_by()
  • get_tag_link()