Some useful functions to paste in your child theme for debugging
Display variable content :
function outpre(&$var) { if(empty($var)) { $output = "variable has no data"; } else { echo "<pre style='background:white;color:navy;margin:5px;padding:10px;border-radius:5px;'>"; print_r($var); echo "</pre>"; } }
Display all functions linked to a specific hook (uses outpre)
function show_hooked(){ $hook_name = 'your_hook_here'; global $wp_filter; outpre( $wp_filter[$hook_name] ); } //add_action('wp_footer', 'show_hooked');
Display all queries fired to generate the page (uses outpre)
function get_db_queries() { $a = 1; global $wpdb; foreach ($wpdb->queries as $query) { echo '<h3>QUERY N°'.$a.'</h3>'; echo '<h4>Query</h4>'; outpre($query); echo '<h4>Result</h4>'; $result = $wpdb->get_results($query[0]); outpre($result); $a++; } wp_cache_flush(); } //add_action( 'wp_footer', 'get_db_queries' );
More details and comments coming soon ! (hopefully…)