Ready to get started?Download WordPress


View Page SQL Queries? (4 posts)

  1. war59312
    Posted 7 years ago #


    Is there anyway to see what queries are running while a wordpress page loads?


    SQL Newbie ;)

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    If you know a little PHP, yes.

    Add this to your wp-config file:
    define('SAVEQUERIES', true);

    Then, somewhere in your template (probably at the end of the footer.php, add this code:
    if (SAVEQUERIES) {
    echo "<!--\n";
    echo "\n-->\n";

    I think that will do it. Anyway, then look at the source of any page and all the queries it ran will be at the bottom.

    Don't leave this turned on, BTW. Turn it off again when you're done looking at the output.

  3. Mark Jaquith
    WordPress Lead Dev
    Posted 7 years ago #

    Alternative... and safer:

    if ( SAVEQUERIES && current_user_can('manage_options') && $_GET['showqueries'] ) {
    echo "<!--n";
    echo "n-->n";

    Then just access http://example.com/?showqueries=1 while logged in as an Administrator level account.

  4. war59312
    Posted 7 years ago #

    Sweet! Thanks to both of you! :)

Topic Closed

This topic has been closed to new replies.

About this Topic