Home / admin / WordPress analyze queries
  • How to WordPress analyze queries

    no thumbnail sorry: WordPress analyze queries

    Adding this PHP code to your wordpress theme will display the number of queries and the time it took.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?php
              echo get_num_queries();
    ?>
    queries.
    <?php
              timer_stop(1);
    ?>
    

    Update.

    Suggested by a commenter, however I made a small update. This wordpress code snippet will display the number of queries and the time it took but only for the admin.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?
                global $current_user;
                get_currentuserinfo();
                if ($current_user->user_level == 10 ) {
                      echo get_num_queries() .'queries' . timer_stop(1);
                }
    ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    get_currentuserinfo, _n, get_num_queries,