The SAVEQUERIES wp-config constant saves database queries to an array and We can use that array to display queries. The information saves each query, what function called it, and how long that query took to execute.
To enable SAVEQUERIES add this to the wp-config.php
file:
define( 'SAVEQUERIES', true );
Then in the footer of your theme put this:
<?php if ( current_user_can( 'administrator' ) ) { global $wpdb; echo "<pre>"; print_r( $wpdb->queries ); echo "</pre>"; } ?>
Open your website and in the footer you will notice queries.
Note: This will have a performance impact on your site, so make sure to turn this off when you aren’t debugging.
Was this post helpful?
Let me know if you liked the post. That’s the only way I can improve. 🙂