Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2019-12-21 22:07:11
- Myusername
- Member
- Registered: 2019-12-12
- Posts: 162
Is it possible to filter posts from at most one week ago?
I am wanting to show you some popular posts filtered by the number of visits. For this, I am using a custom_field to store the number of visits this way:
<txp:php>
global $thisarticle;
safe_update('textpattern', 'custom_1=custom_1+1', 'ID='.$thisarticle['thisid']);
</txp:php>
Then I use the sort
attribute to fit posts by custom_field like this:
<txp:article_custom limit="5" sort='custom_1 + 0 desc'>
However, I didn’t find any way to view posts just from last week. Help me?
Last edited by Myusername (2019-12-21 22:09:04)
Offline
Re: Is it possible to filter posts from at most one week ago?
I am not sure about the exact PHP relative time format but this looks like it could work.
<txp:article_custom limit="5" sort='custom_1 + 0 desc' time="-1 weeks">
Offline
Re: Is it possible to filter posts from at most one week ago?
Myusername wrote #320651:
I am wanting to show you some popular posts filtered by the number of visits. For this, I am using a custom_field to store the number of visits this way …
Have you found a way to effectively filter out visits by search bots and scripts, which can skew the results sometimes dramatically. If there’s a server-side way, I’d be interested to hear how.
From what I’ve read, logging visits via javascript is supposed to be more effective as most (?) bots don’t process javascript.
TXP Builders – finely-crafted code, design and txp
Offline