get_results( "SELECT `pages`.`uri`, `pages`.`id`, SUM(`pages`.`count`) + IFNULL(`historical`.`value`, 0) AS `count_sum` FROM `{$wpdb->prefix}statistics_pages` `pages` LEFT JOIN `{$wpdb->prefix}statistics_historical` `historical` ON `pages`.`uri`=`historical`.`uri` AND `historical`.`category`='uri' GROUP BY `uri` ORDER BY `count_sum` DESC LIMIT 10 " ); $site_url = site_url(); $counter = 0; echo '
'; foreach ( $result as $item ) { $counter += 1; echo '
'; // Lookup the post title. $post = get_post( $item->id ); if ( is_object( $post ) ) { $title = $post->post_title; } else { if ( $item->uri == '/' ) { $title = get_bloginfo(); } else { $title = '[' . __( 'No page title found', 'wp-statistics' ) . ']'; } } echo "
{$counter} - {$title}
"; echo '
' . __( 'Visits', 'wp-statistics' ) . ': ' . number_format_i18n( $item->count_sum ) . '
'; echo '
' . htmlentities( urldecode( $item->uri ), ENT_QUOTES ) . '
'; echo '
'; } echo '
'; }