[[!getPage? &element=`getResources` &tpl=`newsPost` &parents=`4` &limit=`4` &sortby=`{"publishedon":"DESC"}` ]] <div class="pagination">[[!+page.nav]]</div>
This question has been answered by treigh. See the first response.
Take a look at this https://forums.modx.com/thread/43773/getresources-where-publishedon.
Filtering getResources with the where-clause and the Extra getDate.
<?php $ts = !empty($input) ? strtotime($input) : time(); return (string) $ts;
&where=`{"publishedon:>":[[time? &input=`-1 month`]]}`
[[!getPage? &element=`getResources` &tpl=`newsPost` &parents=`4` &limit=`0` &sortby=`{"publishedon":"DESC"}` &where=`{"publishedon:>":[[time? &input=`-1 month`]]}` ]] <div class="pagination">[[!+page.nav]]</div>
Here's one way to do it. All due credit to Opengeek. More on the solution here.
First, create a snippet that returns a unix timestamp. Call it time or whatever you like.
<!--?php $ts = !empty($input) ? strtotime($input) : time(); return (string) $ts;
Then use the returned timestamp to compare against the publishedon field of your resource.
In your getPage call, add a where property:
&where=`{"publishedon:-->":[[time? &input=`-1 month`]]}`
This selects articles published in the current month. If you don't want to limit to 4 articles, set the limit to 0.
Here's your final call:
[[!getPage? &element=`getResources` &tpl=`newsPost` &parents=`4` &limit=`0` &sortby=`{"publishedon":"DESC"}` &where=`{"publishedon:>":[[time? &input=`-1 month`]]}` ]] <div class="pagination">[[!+page.nav]]</div>