WordPressを使っていて、はじめに躓いたのがパスの記述。
ルート相対パスなるものを知ったのだけれど、テスト環境だと使えなかったりもする。
結局、一番使ってるのは
bloginfo('template_url');
だったりする。
テンプレートタグ/bloginfo からの引用
'template_url' / 'template_directory' - アクティブなテーマのディレクトリー URL を表示します。
('template_directory' は Version 2.6 以前ではローカルパスを表示していました。ハック的な代替策は
get_theme_root() と get_template() を参照してください)。 子テーマの中では、 get_bloginfo('template_url') と
get_template() はどちらも親テーマのディレクトリーを返します。そのため、親テーマでは
get_template_directory_uri() を、子テーマでは get_stylesheet_directory_uri() を使うよう考慮してください。
他にも
// プライマリーな CSS (usually style.css) ファイルの URL
bloginfo('stylesheet_url');
get_stylesheet_uri();
// アクティブなテーマディレクトリーの URL
bloginfo('stylesheet_directory');
get_stylesheet_directory_uri();
なんかがあるようだ。
使い分けについては今後の課題。