Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset page/post views #57

Open
stefanpieter opened this issue Nov 10, 2023 · 4 comments
Open

Reset page/post views #57

stefanpieter opened this issue Nov 10, 2023 · 4 comments

Comments

@stefanpieter
Copy link

Hello :-)

When copying a page or post to create a new design it also copies over the page views from the original post/page. How do you reset the view count for a page/post?

Thank you for the great work.

@lesterchan
Copy link
Owner

Just update the "views" post meta of that post to 0.

@stefanpieter
Copy link
Author

Just update the "views" post meta of that post to 0.

How is this done in the WordPress admin panel? Apologies if I am missing something.

@lesterchan
Copy link
Owner

@TuringTux
Copy link

When you have access to the underlying database (e.g. by installing the Adminer plugin), you can execute the following query to reset:

start transaction;
delete from wp_postmeta where meta_key = 'views';

This will start a transaction to delete all the view data. It isn't gone yet, so if you change your mind, you can just execute rollback;. If you are sure you want to delete the data, execute commit;.


Btw: If you want to get a table containing the view data for each post, page and file, you can use:

select p.ID, p.post_title, cast(m.meta_value as signed integer)
as view_cnt, p.guid as url, p.post_type
from wp_postmeta m, wp_posts p
where m.meta_key = 'views'
      and m.post_id = p.ID
order by view_cnt desc;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants