Hi Lubo,
But when I check the data in the database, the views number is much larger (979 views as of now).
Which table did you check? If it was wp_popularpostsdata
, this table stores the total views count (a.k.a. All time) of every post whereas wp_popularpostssumary
stores the views count of the last N days.
If you set the widget to display the top posts from the past 7 days, the views count you’ll see on the list is the one that corresponds to the total views that article received within the past 7 days, not the total views count.
For example:
I’m assuming here you’re using the wpp_get_views() template tag to display the views count of the post. If so, by default this function returns the total views count of the post. So of course this number will always be greater than the views count this post got within the past 7 days, which is:
Hope that clarifies things a bit.
If you have any other questions don’t hesitate to ask, alright?
PS: Your plugin is great!
Thanks, I’m glad you like it!
Thread Starter
zviera
(@zviera)
Thanks for the explanation, Hector. That’s exactly how I understood it.
My client has let me know when the post hasn’t been published more than 7 days yet, so the data should be the same. But since it’s been over 7 days since then, we can’t see it now.
But anyway, it was just one post and it seems to work fine now, so I will keep an eye on it and will let you know if it happens again.
Thanks.
Thread Starter
zviera
(@zviera)
Hi Hector,
so my client has noticed the same thing again – one article having much less views as the others. The article is this: Article.
Total view count (from wp_popularpostsdata table): 772
Date of publishing the article: 2019-05-29 17:48:20
Date now: 2019-06-05 5:26 (So it’s still less then 7 days)
But view count for the last 7 days (from xxkikxpopularpostssummary table): 462
Okay, I think I have found out what the issue is. In your plugin’s admin stats page, when I chose to show the stats from the last 7 days, it shows the date range as follows: “may, Th 30 — jun, We 05”.
So it seems that when I chose the “range => last7days” using your shortcode, it counts in the current day and the previous 6 days. And if the article was published in the evening, on the seventh day in the morning, the stats don’t count the views from the first day, and that creates the mismatch.
Is there a way how you could fix this?
Thank you.
Lubo
Hi @zviera,
So it seems that when I chose the “range => last7days” using your shortcode, it counts in the current day and the previous 6 days.
The same is true for the Stats section, actually.
When you ask the plugin to return the top viewed posts within a selected time range, WPP uses the current date & time as the starting point. For example:
2019-06-05 08:01:33 – 2019-05-30 08:01:33
Taking your date as the starting point:
2019-06-05 05:26:00 – 2019-05-30 05:26:00
That’s 7 days, today included. If your post was created on 2019-05-29, that’s 1 day older than the selected time range (last 7 days) so, of course, the views count won’t match.
Hope that clarifies things.
Thread Starter
zviera
(@zviera)
Hi @hcabrera
The same is true for the Stats section, actually.
I know, but only when you chose the “Last 7 days” tab. When you chose the “Custom” tab and there you pick 7 days, it shows correctly – the way we need it.
This is the screen of the “7d” tab: https://www.dropbox.com/s/z251ezngcv6ds42/7days.png?dl=0
This is the screen of the “Custom” tab with 7 days: https://www.dropbox.com/s/89kwzzhk3qfmoyp/custom.png?dl=0
I think I can solve this issue by using the “custom” option of the date range in your shortcode. But I haven’t found in the documentation how to use it. Would you provide me an example shortcode here please?
Thank you!
Lubo
I know, but only when you chose the “Last 7 days” tab. When you chose the “Custom” tab and there you pick 7 days, it shows correctly – the way we need it.
This is the screen of the “Custom” tab with 7 days: https://www.dropbox.com/s/89kwzzhk3qfmoyp/custom.png?dl=0
You’re displaying here 8 days of data, actually: first 7 days of the month + May 31th.
Anyways, this will give you the results you’re looking for:
[wpp range='custom' time_quantity=8 time_unit='day']
Thread Starter
zviera
(@zviera)
You’re displaying here 8 days of data, actually: first 7 days of the month + May 31th.
That’s okay. I think it will be less confusing for my client’s readers now (especially in the morning of the 8th day).
And actually, the correct shortcode is this:
[wpp range='custom' time_quantity=7 time_unit='day']
Thank you!
And actually, the correct shortcode is this:
[wpp range='custom' time_quantity=7 time_unit='day']
Ah, that’s a bug right there. That should return the exact same result as [wpp range='last7days']
. I’ll have that fixed on the next release so thanks for the notice.
Thread Starter
zviera
(@zviera)
That’s exactly what I was trying to explain to you already in my first post, so I am glad we have cleared that up 🙂
“last7days” return 7 days of data so there was no bug there. The bug is that when using:
[wpp range='custom' time_quantity=7 time_unit='day']
… this returns 8 days of data instead of 7, and that’s what I’m fixing. What you were reporting wasn’t a bug but a misunderstanding on your & your client’s part.
Thread Starter
zviera
(@zviera)
No, I understood that.
Also, when I chose “Custom” in the backend stats page and chose 7 days, the number is correct.
This is a quote from my first post, where I noticed that when chosing the custom option with 7 days, the numbers are different than when using the last7days option. That’s what I meant 🙂
This is what you said:
Also, when I chose “Custom” in the backend stats page and chose 7 days, the number is correct. It seems that only the pre-set 7 days (“7d”) count is for some reason wrong for this one article.
Hence the confusion. It’s the other way around actually: it’s the custom time range that’s not working as it should, so now we’re on the same page 😛
I’ll mark this topic as unresolved until a proper fix is ready.