// 使用中テンプレ出す functions.phpに一れる
add_action('wp_footer', function () {
if ( ! is_user_logged_in() || ! current_user_can('administrator') ) {
return; // 管理者ログイン時のみ表示
}
$locations = [
'header' => 'ヘッダー',
'footer' => 'フッター',
'single' => 'シングル',
'archive' => 'アーカイブ',
'404' => '404ページ',
'search' => '検索結果',
'page' => '固定ページ',
];
echo '<div style="position:fixed; bottom:0; left:0; background:#333; color:#fff; padding:10px; z-index:99999; font-size:12px;">';
echo '<strong>【Elementor使用テンプレート一覧】</strong><br>';
foreach ( $locations as $location => $label ) {
$templates = \ElementorPro\Modules\ThemeBuilder\Module::instance()
->get_conditions_manager()
->get_documents_for_location( $location );
if ( ! empty( $templates ) ) {
foreach ( $templates as $template ) {
echo esc_html("{$label}:ID={$template->get_id()} / タイトル={$template->get_title()}") . '<br>';
break; // 最初のテンプレだけ表示
}
}
}
echo '</div>';
});
Elementorを使っていてどのテンプレで出てるっけ!?ってよくなるので
管理者にだけフロントに出すコードを何回も書いてたので
次からコピペできるようにしました。