Popular Sort – Limit to range of publish date

Posted in: Newspaper
Post count: 104

As I understand it, the sorting feature is set to prioritize ‘popularity’ over a set period of time – 24 hours, 48 hours, or 7 days. However, this feature sorts content based on the number of views rather than the publish date. As a result, an older article that continually attracts a high number of views would maintain its top position indefinitely.

I’m wondering, is there a code snippet or filter that could refine this process by integrating a date range? For instance, can we gather all posts published within the last 7 days and then sort these by the number of views? This way, the system would display posts with the highest view counts but only from the most recent 7-day period, thereby allowing more recent content a chance to rise in the rankings.

I know I could alter the code, but of course on updates that would be lost and have to manually add again.
Appreciate any feedback on this.

Post count: 27744

Hello,

Unfortunately, the theme doesn’t5 have a filter like that.
You can add the code in the child theme.

Thank you!

Post count: 29

What filter should we hook at functions.php in order
to limit the query of popular to posts of last days eg 7 only?

thanks

Post count: 27744

Hi,

Hi,

Unfortunately, I don’t have the necessary knowledge on exactly how it should be done. This request requires more knowledge; if you want, you can contact our team for custom work, and they will tell you if it can be implemented -> https://tagdiv.com/web-development-services/

Thank you!

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