Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ----------------------------------------------------------------------
- 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)
- */
- if ($sort == 'jetpack_popular_2') {
- if (function_exists('stats_get_csv')) {
- // the damn jetpack api cannot return only posts so it may return pages. That's why we query with a bigger + 5 limit
- // so that if the api returns also 5 pages mixed with the post we will still have the desired number of posts
- $jetpack_api_posts = stats_get_csv('postviews', array(
- 'days' => 2,
- 'limit' => $limit + 5
- ));
- if (!empty($jetpack_api_posts) and is_array($jetpack_api_posts)) {
- $wp_query_args['post__in'] = wp_list_pluck($jetpack_api_posts, 'post_id');
- $wp_query_args['posts_per_page'] = $limit;
- return $wp_query_args;
- }
- }
- return array(); // empty array makes WP_Query not run
- }
Advertisement
Add Comment
Please, Sign In to add comment