Hi,
That’s a bit of a misunderstanding here. The reset data feature is removing “single day” entries – it does not remove overall views count.
There is a way to achieve what you described. For now it requires to use a WP filter, but there are plans to introduce some more user-friendly methods.
First, paste this into functions.php of your theme:
function pvc_custom_posts_join($join, $query) {
global $wpdb;
// the key part is pvc.type = 0, 0 is for daily views
if(isset($query->order_by_post_views) && $query->order_by_post_views)
$join .= " LEFT JOIN ".$wpdb->prefix."post_views pvc ON pvc.id = ".$wpdb->prefix."posts.ID AND pvc.type = 0";
return $join;
}
add_filter('posts_join', 'pvc_custom_posts_join', 11, 2);
Then you just run standard WP query, with “orderby” parameter set to “post_views”, to get the desired posts ordered by post views.
Thanks for the code, but when I use it I receive the following error:
WordPress database error: [Not unique table/alias: 'pvc']
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_posts AS p2 ON (wp_posts.post_parent = p2.ID) LEFT JOIN wp_post_views pvc ON pvc.id = wp_posts.ID AND pvc.type = 4 LEFT JOIN wp_post_views pvc ON pvc.id = wp_posts.ID AND pvc.type = 0 WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (21,31,33,34,42,43,44) ) AND wp_posts.post_type = 'page' AND (((wp_posts.post_status = 'publish') OR (wp_posts.post_status = 'inherit' AND (p2.post_status = 'publish')))) GROUP BY wp_posts.ID, wp_posts.ID ORDER BY pvc.count DESC, wp_posts.ID DESC LIMIT 0, 12
Any ideas?
I didn’t test that. But as the message says try changing pvc alias to seomthing different (pvc2)