Created
February 24, 2016 22:27
-
-
Save digitalinkwell/43f1632441b2f477bd70 to your computer and use it in GitHub Desktop.
Get Jetpack post views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // extract JetPack pageviews | |
| // courtesy of Topher: http://wpgr.org/2013/03/02/rendering-jetpack-stats/ | |
| function get_page_views($post_id) { | |
| if (function_exists('stats_get_csv')) { | |
| $args = array('days'=>-1, 'limit'=>-1, 'post_id'=>$post_id); | |
| $result = stats_get_csv('postviews', $args); | |
| $views = $result[0]['views']; | |
| } else { | |
| $views = 0; | |
| } | |
| return number_format_i18n($views); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment