• Hey,

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

    Thanks,

    SQL Newbie ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    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";
    print_r($wpdb->queries);
    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.

    Alternative… and safer:


    <?php
    if ( SAVEQUERIES && current_user_can('manage_options') && $_GET['showqueries'] ) {
    echo "<!--n";
    print_r($wpdb->queries);
    echo "n-->n";
    }
    ?>

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

    Thread Starter war59312

    (@war59312)

    Sweet! Thanks to both of you! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘View Page SQL Queries?’ is closed to new replies.