WordPress mainly provides two statistical functions
1. Publicly display the statistical information of the query
-
<p? style= "text-align:center;color:#3A90F2" >Number of queries<? php? echo ? get_num_queries();?>? Times, the total time consumption is?<? php?timer_stop(1);??>? Seconds</ p>
2. Display the statistics in the source code instead of the content of the page
-
<!--? Number of queries<? php? echo ? get_num_queries();??> Times,? Time consumption?<?? php?timer_stop(1);??>? Seconds? -->
3. Statistical information can only be seen after you log in
-
<? php -
if ? (current_user_can('level_10')) -
{ -
???? echo ?' Number of queries<! --? '? get_num_queries()?.?'? Time, time consumption:? timer_stop(1)?.?'? Seconds? -->'; -
} -
?>
Extension
-
define('SAVEQUERIES',? true);
-
<? php -
if ? (is_user_logged_in()) -
{ -
???? global ? $wpdb ; -
???? echo ? "<pre>" ; -
???? print_r( $wpdb ->queries); -
???? echo ? "</pre>" ; -
} -
?>
-
? if (is_user_logged_in()) It is used to determine whether the current visitor has logged in or not if (current_user_can('level_10')) To determine whether it is an administrator login, in order to prevent tourists from viewing these data, this code can be saved; global $wpdb; Defining Global Variables $wpdb , which is the default database class of Wordpress; <pre></pre> ? Nest results in HTML tags? <pre> ? Internal; print_r($wpdb->queries); Output the information of each database query.
-
Array -
??? ( -
??????? [0]?=>? Array -
??????????? ( -
??????????????? [0]?=>?? SELECT?SQL_CALC_FOUND_ROWS??wp_posts.*?FROM?wp_posts??WHERE?1=1??AND?wp_posts.post_type?=?'post'?AND? (wp_posts.post_status?=?'publish'? OR?wp_posts.post_status?=?' private ')?? ORDER?BY?wp_posts.post_date?DESC?LIMIT?0,?10 -
??????????????? [1]?=>? zero point zero zero zero three nine six zero one three two five nine eight eight seven seven -
??????????????? [2]?=>? require ,? wp,?WP->main,?WP->query_posts,?WP_Query->query,?WP_Query->get_posts -
???????????) -
??????? [1]?=>? Array -
??????????? ( -
??????????????? [0]?=>? SELECT?option_value?FROM?wp_options?WHERE?option_name?=?'nuodou_header_code'?LIMIT?1 -
??????????????? [1]?=>? zero point zero zero one three five eight nine eight five nine zero zero eight seven eight nine -
??????????????? [2]?=>? require ,? require_once ,? include ,? get_header,?locate_template,?load_template,? require_once ,? get_option -
???????????)