この記事では、1年以上前に書かれた記事です。状況は今異なっている可能性があることに注意してください。
子テーマを作成する時など、いまどのテンプレートファイルを読み込んでるのかをヘッダーの上に表示する。
あくまでもデバッグ用なので、終わったら消して(無効化)して下さい。
1 2 3 4 5 6 7 8 |
function header_get_page_template(){ global $template; $temp_path = str_replace( get_theme_root() ,'', $template ); echo 'Template Path: '; echo $temp_path . '<br>'; } add_filter('wp_head', 'header_get_page_template'); |
また、wp-contentのthemesの中の読込んだファイルをフッターに表示するツールも作ってみました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
add_action( 'wp_footer', 'trace_included_files' ); function trace_included_files() { // echo php_uname()."<br>"; // echo PHP_OS."<br>"; // Const // $delimiter = '\\'; // For Windows $delimiter = DIRECTORY_SEPARATOR; // Site Dir $site_dir = ABSPATH; $site_dir = str_replace("/", "\\", $site_dir ); // Get Themes Dir $theme_dir = get_stylesheet_directory(); $theme_dir = str_replace("/", "\\", $theme_dir ); $plugin_dir = WP_PLUGIN_DIR; $plugin_dir = str_replace("/", "\\", $plugin_dir ); // Get All include Files $include_files = get_included_files(); $dir_arrays = array(); foreach ($include_files as $key => $value) { $include_path = pathinfo($value); $include_dir = $include_path['dirname']; $short_value = str_replace($site_dir, '', $value); $short_value_array = pathinfo($short_value); $short_value_args = explode($delimiter, $short_value_array['dirname']); $short_value_temp['dirname'] = $short_value_args; $short_value_temp['basename'] = $short_value_array['basename']; array_push($dir_arrays, $short_value_temp); // Sapalete Full Dir $each_dir_name = explode( $delimiter, $include_dir); } echo '<table border=1>'; echo '<tr><th>[Path]</th><th>[File]</th></tr>'; foreach ($dir_arrays as $dir_array) { if (($dir_array['dirname'][0] === 'wp-content') AND ($dir_array['dirname'][1] === 'themes')) { echo '<tr>'; echo '<td>'; $dir_array_basename = null; $dir_array_basenames = $dir_array['dirname']; foreach ($dir_array_basenames as $dir_array_key => $dir_array_value ) { if ($dir_array_key != 0) { echo '/'; } echo $dir_array_value; } echo '<td>'; echo $dir_array['basename']; echo '</td>'; echo '</tr>'; } } echo '</table>'; } |
表示条件を変えたい場合は、49行目の条件を変えてみてください。