7 days sorting (popular) not working

Posted in: Newspaper
Post count: 39

I have a staging server that only I have access to. I did the following:

– Added Big Grid 3 with Popular (last 7 days)
– Enabled Post Views at Post Settings > Post and Custom Post Types > Show Post Views
– Enabled “Use 7 days post sorting” at Block Settings > 7 days post sorting
– No caching is enabled

I load an article and refresh the page in order to increase the view count. At no point does this article show in the Big Grid 3 despite none of the other articles being accessed.

How long should it take to populate this section? Also, is there any way to check the current 7 day count?

Post count: 39

I enabled custom fields and checked the 7 day view count. The top articles are showing thousands of views in the last 7 days, but this can not be correct. How and when does this counter reset? Is there any way to force all counts to zero?

  • This reply was modified 10 years by iip.
Post count: 39

To continue this thread… I was looking at the code and it seems that if a post is not viewed on the current day, its number will persist from the previous week. Shouldn’t there be a function that resets all current day values in the database to 0 at the beginning of each day? The only time a number is reset is when the specific article is viewed and the last day for the article does not match the current day.

For example, if an article has 1000 views on Thursday of the previous week, but this week, the article receives zero views on Thursday, that 1000 will not be overwritten in the array because the article was not viewed.

I have several articles with bloated 7 day arrays which may or may not be viewed on any given day. Subsequently, on days they are not viewed, their previous values will persist.

Of course, this could be self-correcting because if they are promoted to the 7 day popular list, they should receive views if it is working as intended. However, the logic still seems flawed.

  • This reply was modified 10 years by iip.
  • This reply was modified 10 years by iip.
Post count: 22421

Hello,
The sorting option works as expected. We have no reported bugs with this method. If no cache is installed then the posts with the most views from the last 7 days will be displayed. DId you enable this option in the theme panel? http://screencast.com/t/aaarhvqy3Gkm (without it the sorting options will not work: https://forum.tagdiv.com/7-days-post-sorting/)
Please follow the guide and test the sorting option again.
Thank you!

Post count: 39

Sorry Bogdan, please review the rest of my posts as I’ve covered everything that you mention here. Here’s a specific example…

One of our old articles has this for its 7-day array:
a:7:{i:0;i:371;i:1;i:363;i:2;i:142;i:3;i:107;i:4;i:55;i:5;i:1539;i:6;i:1472;}

However, it has not been viewed in months. Unless this article is viewed on days 5 and 6, it will retain those views for that day and eventually, when the weekly numbers are the highest, will show in the 7 day popular block.

Can we delete all entries from the database for post_views_count_7_day_total and post_views_count_7_day_arr? Will this reset the list? Or will it cause an issue?

Post count: 19

Hello,

i have the same problem.

Any help ?

Post count: 1291

Hi,

Thanks for reporting this issue. The 7 days system was built with the idea that each post will receive at least one view each day. This was a bad assumption and we plan to fix it, it’s on our list and it will be modified on one of the next updates. Sorry for the inconvenience.

A function which updates the count at the beginning of each day for all the posts is problematic because there are sites which have thousands of posts and such an operation would kill their functionality. We plan to take another approach which doesn’t interfere with the site performance in any way.

The 7 days array is stored in the post meta and it can be deleted using wp-cli – http://wp-cli.org/commands/post/meta/
Or delete_post_meta – https://codex.wordpress.org/Function_Reference/delete_post_meta
Or a database query – http://blog.grapii.com/2012/08/remove-custom-fields-from-wordpress-database-using-sql/
Look for the following keys – http://screencast.com/t/9ZAehdEYidjR
If the 7 days array is not set, the theme creates a new one and sets the last_day and the total parameters – http://screencast.com/t/bcZToUIfPL

Before trying this make sure backup your database – https://codex.wordpress.org/WordPress_Backups#Database_Backup_Instructions

Thank you!

Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.