Guest User

Untitled

a guest
Oct 13th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /* ----------------------------------------------------------------------
  2. jetpack sorting - this will return here if that's the case because it dosn't work with other filters (it's site wide, no category + this or other combinations)
  3. */
  4. if ($sort == 'jetpack_popular_2') {
  5. if (function_exists('stats_get_csv')) {
  6. // the damn jetpack api cannot return only posts so it may return pages. That's why we query with a bigger + 5 limit
  7. // so that if the api returns also 5 pages mixed with the post we will still have the desired number of posts
  8. $jetpack_api_posts = stats_get_csv('postviews', array(
  9. 'days' => 2,
  10. 'limit' => $limit + 5
  11. ));
  12. if (!empty($jetpack_api_posts) and is_array($jetpack_api_posts)) {
  13. $wp_query_args['post__in'] = wp_list_pluck($jetpack_api_posts, 'post_id');
  14. $wp_query_args['posts_per_page'] = $limit;
  15.  
  16. return $wp_query_args;
  17. }
  18. }
  19. return array(); // empty array makes WP_Query not run
  20. }
Advertisement
Add Comment
Please, Sign In to add comment