I forgot, there is also this script that is put in the functions.php file:
//This function works in conjunction with the WordPress.com Stats plugin.
//You need it for the Most Popular widget.
function get_stats_exclude_home($numDays,$numPosts) {
$numPostsPlus = $numPosts + 1;
$blnHasHome = false;
$intRowsLoop = 0;
$intRowFound;
$intRowsCount;
$most_read_posts;
$strArgs = ‘days=’ . $numDays . ‘&limit=’ . $numPostsPlus;
if (function_exists(‘stats_get_csv’)) {
$most_read_posts = stats_get_csv(‘postviews’, $strArgs);
}
foreach ($most_read_posts as $single_post) {
$postTitle = $single_post[‘post_title’];
if($postTitle == ‘Home page’) {
$blnHasHome = true;
$intRowFound = $intRowsLoop;
}
$intRowsLoop = $intRowsLoop + 1;
}
$intRowsCount = $intRowsLoop + 1;
if($blnHasHome) {
unset($most_read_posts[$intRowFound]);
} else {
if($intRowsCount > $numPosts){
unset($most_read_posts[$numPosts]);
}
}
return $most_read_posts;
}
?>
You can indeed use stats_get_csv to display Stats collected by Jetpack. You can find some examples here:
http://wpgr.org/2013/03/02/rendering-jetpack-stats/
http://ww.wp.xz.cn/plugins/jetpack-post-views/
You can check the different parameters allowed by the WordPress.com Stats API here:
http://stats.wordpress.com/csv.php
Thanks!
I had found the wpgr post via google, but it’s not quite what I need to do.
The jetpack post views module might work, this script might be handy:
<?php if ( function_exists(‘JPV_display_top_posts’) ) { JPV_display_top_posts( $args ); } ?>
Luckily, it looks like the old script still works. I wish the csv.php page had more code samples!
I wish the csv.php page had more code samples!
We probably won’t make any changes to that page. We’ve started adding Stat data to the REST API:
http://developer.wordpress.com/docs/api/1/get/sites/%24site/stats/
Keep an eye on our Developer blog, we’ll probably post about the new Stats endpoint soon!