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 ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset page/post views #57

Open
stefanpieteropened this issue Nov 10, 2023 · 4 comments
Open

Reset page/post views #57

stefanpieteropened 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 theAdminer plugin), you can execute the following query to reset:

start transaction;
deletefromwp_postmetawheremeta_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 executerollback;.If you are sure you want to delete the data, executecommit;.


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

selectp.ID,p.post_title,cast(m.meta_valueassignedinteger)
asview_cnt,p.guidasurl,p.post_type
fromwp_postmeta m, wp_posts p
wherem.meta_key='views'
andm.post_id=p.ID
order byview_cntdesc;

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