Jump to content

Find pages with grand children older than x days, but not newer than x days


suntrop
 Share

Recommended Posts

I was trying to get pages that have grand children older than 14 days, but not newer than 14 days.

$cities = wire('pages')->find('template=city, !children.children.created>"14 days ago"');

$cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->not('template=city, children.children.created>"14 days ago"');

$cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->remove('template=city, children.children.created>"14 days ago"');

The first one is, I guess, not supported by PW (not to mention something like created!>time), but the last two should work in my option. The filter() doesn't work either here.

Please note, that all city pages have grand children older than 14 days, so I can't just find('template=cities, children.children.created<"14 days ago"') because that includes those pages having grand children from yesterday for example.

Link to comment
Share on other sites

Hadn't luck with timestamp either. Changed it now to this, and it's working for me. Anyway, thanks for your answer!

$remove = wire('pages')->find('template=city, children.children.created>"14 days ago"');
$cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->removeItems($remove);

 

Link to comment
Share on other sites

1 hour ago, LostKobrakai said:

 


$cities = wire('pages')->find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"')

 

This one has a strange outcome. For example …

find('template=city, children.children.created<"14 days ago"');

Result:

  • Hamburg
  • Berlin
  • Hannover
  • Wiesbaden

 

find('template=city, children.children.created>"14 days ago"');

Result:

  • Hamburg
  • Bremen

 

find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"');

Result:

  • Hamburg
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...