twoeight
3/22/2017 - 12:16 PM

How to debug Wordpress From https://magicpress.net/2017/03/22/how-to-debug-a-wordpress-theme/

if( current_user_can( 'administrator' ) ) {
    function show_template() {
        global $template;
        echo '<div style="position: fixed; bottom: 10px; left: 10px; background-color: rgba(0,0,0,0.5); padding: 10px; z-index: 99999999; color: #fff;">';
        print_r($template);
        echo '</div>';
        echo '<pre><ol>';
        $files = get_included_files();
        foreach ($files as $key => $path) {
            if(strstr($path, ABSPATH.'wp-content/themes/')){
                echo '<li>'.str_replace(ABSPATH.'wp-content/themes/','', $path).'</pre>';
            }
        }
        echo '</ol></pre>';
        echo '</div>';
    }
    add_action('wp_head', 'show_template');
}