Jump to content

Excluding current page from results


maddmac
 Share

Recommended Posts

What's the best way to exclude the current page from results without resorting to filtering the results in a FOR LOOP.

$news = $pages->find("template=news-article,sort=-publish_date, publish_date<$today"); 

In this example If I want to exclude the current page how would I do that?  

Is there a sibling reference?

Link to comment
Share on other sites

24 minutes ago, maddmac said:

In this example If I want to exclude the current page how would I do that?  

$news = $pages->find("template=news-article,sort=-publish_date, publish_date<$today,id!={$page->id}"); 

PS: if publish_date is a datetime field, then ProcessWire already knows 'today' (string) ?

  • Like 3
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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