Title: Reset Data doesn&#039;t work
Last modified: August 22, 2016

---

# Reset Data doesn't work

 *  [Coremmo](https://wordpress.org/support/users/coremmo/)
 * (@coremmo)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/reset-data-doesnt-work/)
 * Hello,
 * first of all: great plugin for bigger sites, no performance issues.
 * I have a problem though: The rest data function doesn’t work, even after deactivating
   all plugins and using a standard wordpress theme. And the data stays after deleting
   and installing your plugin again (yes, I’ve used the function to delete data 
   after deactivation).
 * Background: I want to create a most popular widget in my theme but only based
   on the last 7 days, thus I need my data to reset every 7 days. Sadly, it doesn’t
   work.
 * Would appreciate your help a lot!
 * Thanks
    Kind regards
 * [https://wordpress.org/plugins/post-views-counter/](https://wordpress.org/plugins/post-views-counter/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [dFactory](https://wordpress.org/support/users/dfactory/)
 * (@dfactory)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/reset-data-doesnt-work/#post-5953599)
 * 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.
 *  [GhostPool](https://wordpress.org/support/users/ghostpool/)
 * (@ghostpool)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/reset-data-doesnt-work/#post-5953747)
 * 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?
 *  Plugin Author [dFactory](https://wordpress.org/support/users/dfactory/)
 * (@dfactory)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/reset-data-doesnt-work/#post-5953748)
 * I didn’t test that. But as the message says try changing pvc alias to seomthing
   different (pvc2)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Reset Data doesn't work’ is closed to new replies.

 * ![](https://ps.w.org/post-views-counter/assets/icon-256x256.png?rev=2973820)
 * [Post Views Counter](https://wordpress.org/plugins/post-views-counter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-views-counter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-views-counter/)
 * [Active Topics](https://wordpress.org/support/plugin/post-views-counter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-views-counter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-views-counter/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [dFactory](https://wordpress.org/support/users/dfactory/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/reset-data-doesnt-work/#post-5953748)
 * Status: not resolved